-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathentrypoint.sh
More file actions
37 lines (30 loc) · 1.24 KB
/
Copy pathentrypoint.sh
File metadata and controls
37 lines (30 loc) · 1.24 KB
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
#!/usr/bin/env bash
# Exit immediately if a command exits with a non-zero status
set -e
# If the CRON_SCHEDULE and DOCKCHECK_ARGS environment variables are set, create the crontab entry for the dockcheck user
if [ -n "$CRON_SCHEDULE" ] && [ -n "$DOCKCHECK_ARGS" ]; then
# Write the environment variable content to a temporary file, ensuring a newline at the end
echo "$CRON_SCHEDULE" /app/dockcheck.sh $DOCKCHECK_ARGS > /app/crontab
if [ -n "$DOCKCHECK_ONSTART" ]; then
echo "Executing: dockcheck $DOCKCHECK_ARGS"
/app/dockcheck.sh $DOCKCHECK_ARGS
fi
# Support additional schedule variables
for schedule_var in "${!CRON_SCHEDULE_@}"; do
suffix="${schedule_var#CRON_SCHEDULE_}"
schedule_value="${!schedule_var}"
args_var="DOCKCHECK_ARGS_${suffix}"
args_value="${!args_var}"
echo "$schedule_value" /app/dockcheck.sh $args_value >> /app/crontab
onstart_var="DOCKCHECK_ONSTART_${suffix}"
if [ -n "${!onstart_var}" ]; then
echo "Executing: dockcheck $args_value"
/app/dockcheck.sh $args_value
fi
done
echo "Crontab created."
else
echo "No CRON_SCHEDULE or DOCKCHECK_ARGS environment variable(s) found. No crontab created."
fi
# Pass control to the CMD command specified in the Dockerfile
exec "$@"