Initial commit

This commit is contained in:
2025-11-29 15:24:11 -08:00
parent f91705ebf1
commit 8479c98e39
6 changed files with 690 additions and 1 deletions

42
start.sh Normal file
View File

@@ -0,0 +1,42 @@
#!/bin/sh
set -e
# Ensure data directory exists
mkdir -p /var/www/data/speed
# Ensure raw data file exists
touch /var/www/data/speed/raw.speedtest.json
# If the data directory is a mounted volume it may be owned by root; allow writes
# by ensuring the directory is writable.
chown -R root:root /var/www/data || true
chmod -R a+rwX /var/www/data || true
# Run the initial speed test once (in background) to populate files if possible
# 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"
else
(crontab -l 2>/dev/null; echo "$CRON_ENTRY") | crontab -
echo "installed cron entry into root crontab"
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"
busybox httpd -f -p ${PORT} -h /var/www
else
echo "warning: busybox httpd not found; container will keep running with cron only" >&2
# keep the script running so container doesn't exit
tail -f /var/log/cron.log
fi