1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-07-12 20:34:38 +03:00

Added UID and GID environment variables to allow execution as non-root

user

fixes #2
This commit is contained in:
10
2019-05-11 02:39:56 +02:00
parent b30b631e34
commit b9fe712fda
4 changed files with 55 additions and 36 deletions

31
entrypoint.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/sh
#set -ux
BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh"
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