1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-06-28 02:28:14 +03:00
vwdump/entrypoint.sh
2019-05-24 01:40:45 +02:00

46 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# vim: tabstop=2 shiftwidth=2 expandtab
#set -ux
BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh"
# For compatibility reasons
if [ "$1" = "/backup.sh" ]; then
>&2 echo "Using /backup.sh is deprecated and will be removed in future versions! Please use \`manual\` as arugment instead"
$BACKUP_CMD
fi
# Just run the backup script
if [ "$1" = "manual" ]; then
$BACKUP_CMD
fi
exit 0
# Initialize cron
echo "Running as $(id)"
if [ "$(id -u)" -eq 0 ] && [ "$(grep -c "$BACKUP_CMD" "$CRONFILE")" -eq 0 ]; then
echo "Initalizing..."
echo "$CRON_TIME $BACKUP_CMD >> $LOGFILE 2>&1" | crontab -
# 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
fi
# Restart script as user "app:app"
if [ "$(id -u)" -eq 0 ]; then
exec su-exec app:app "$0" "$@"
fi
if [ ! -e "$DB_FILE" ]
then
echo "Database $DB_FILE not found!\nPlease check if you mounted the bitwarden_rs volume with '--volumes-from=bitwarden'"!
exit 1;
fi
echo "$(date "+%F %T") - Container started" > "$LOGFILE"
tail -F "$LOGFILE" /app/log/cron.log