1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-06-28 03:08:14 +03:00
vwdump/entrypoint.sh
jmqm 734956821c
Fix execution scheduling (#7)
**Dockerfile**
- Fix `CRON_TIME`.

**backup.sh**
- Remove `TIMESTAMP` variable.
- Change how `date` is displayed when `echo`ing.
2021-05-26 00:57:04 -05:00

34 lines
847 B
Bash
Executable File

#!/bin/sh
BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh"
echo "Running $(basename "$0") as $(id)"
# Run backup script once ($1 = First argument passed).
if [ "$1" = "manual" ]; then
$BACKUP_CMD
exit 0
fi
# Initialize cron
if [ "$(id -u)" -eq 0 ] && [ "$(grep -c "$BACKUP_CMD" "$CRONFILE")" -eq 0 ]; then
echo "Initalizing..."
echo "Writing backup command \"$BACKUP_CMD\" to cron."
echo "$CRON_TIME $BACKUP_CMD >> $LOGFILE 2>&1" | crontab -
fi
# Start crond if it's not running
pgrep crond > /dev/null 2>&1
if [ $? -ne 0 ]; then
/usr/sbin/crond -L /app/log/cron.log
fi
# Restart script as user "app:app"
if [ "$(id -u)" -eq 0 ]; then
echo "Restarting $(basename "$0") as app:app"
exec su-exec app:app "$0" "$@"
fi
echo "[INFO] Container started at $(date +"%F %r")" > "$LOGFILE"
tail -F "$LOGFILE" /app/log/cron.log