forked from Shnezzin/breitbandmessung
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
37 lines (31 loc) · 1002 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -e
source config.shlib;
TZ="$(config_get timezone)";
CRON_SCHEDULE="$(config_get crontab)";
RUN_ONCE="$(config_get run_once | tr -cd "'[:alnum:]")";
RUN_ON_STARTUP="$(config_get run_on_startup | tr -cd "'[:alnum:]")";
export MOZ_HEADLESS=1
echo "Setting timezone: $TZ"
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/$TZ /etc/localtime
echo "Run on startup: ${RUN_ON_STARTUP}"
if [ "$RUN_ON_STARTUP" = "true" ]; then
"/usr/src/app/speedtest.py" > /proc/self/fd/1 2>/proc/self/fd/2
if [ "$RUN_ONCE" = "true" ]; then
echo "Run once: ${RUN_ONCE}"
echo "Exiting..."
exit 0
fi
fi
echo "Run once: ${RUN_ONCE}"
if [ "$RUN_ONCE" = "false" ]; then
printenv | sed 's/^\(.*\)$/export \1/g' > /root/project_env.sh
echo "Setting cron schedule: ${CRON_SCHEDULE}"
echo "${CRON_SCHEDULE} '/usr/src/app/speedtest.py' > /proc/self/fd/1 2>/proc/self/fd/2" | crontab -
cron -f
else
"/usr/src/app/speedtest.py" > /proc/self/fd/1 2>/proc/self/fd/2
echo "Exiting..."
exit 0
fi