Added new parameter CRON_MINUTE to docker image
This can be used to start the cron on a specific minute within the hour. By default, the cron will run in the 10th minute
This commit is contained in:
16
start.sh
16
start.sh
@@ -2,6 +2,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
CRON_MINUTE=${CRON_MINUTE:-10}
|
||||
PORT=${PORT:-8080}
|
||||
|
||||
# Ensure data directory exists
|
||||
mkdir -p /var/www/data/speed
|
||||
|
||||
@@ -17,20 +20,17 @@ chmod -R a+rwX /var/www/data || true
|
||||
# We run it in background so server starts promptly. The cron will run hourly.
|
||||
/usr/local/bin/run_speed_test.sh || true &
|
||||
|
||||
# Ensure the cron job exists in root's crontab (so `crontab -l` shows it)
|
||||
CRON_ENTRY="* * * * * /usr/local/bin/run_speed_test.sh >> /var/log/cron.log 2>&1"
|
||||
if crontab -l 2>/dev/null | grep -F "$CRON_ENTRY" >/dev/null 2>&1; then
|
||||
echo "cron entry already present"
|
||||
# Ensure the cron job exists in Cron
|
||||
CRON_FILE=/etc/cron.d/speedtest-cron
|
||||
if grep run_speed_test ${CRON_FILE}; then
|
||||
echo "cron entry already present"
|
||||
else
|
||||
(crontab -l 2>/dev/null; echo "$CRON_ENTRY") | crontab -
|
||||
echo "installed cron entry into root crontab"
|
||||
echo ${CRON_MINUTE} '* * * * /usr/local/bin/run_speed_test.sh >> /var/log/cron.log 2>&1' > ${CRON_FILE}
|
||||
fi
|
||||
|
||||
# Start Debian cron in background
|
||||
service cron start || cron || true
|
||||
|
||||
PORT=${PORT:-8080}
|
||||
|
||||
# Start busybox httpd serving /var/www on configured port in foreground
|
||||
if command -v busybox >/dev/null 2>&1; then
|
||||
echo "starting busybox httpd on port ${PORT} serving /var/www"
|
||||
|
||||
Reference in New Issue
Block a user