From bc6c9b6d488cdd13ddd3f03017d268c4d1b682a2 Mon Sep 17 00:00:00 2001 From: 1O <2408212-1O@users.noreply.gitlab.com> Date: Sun, 6 Sep 2020 21:13:33 +0200 Subject: [PATCH] fixed permission issues Fixes #12 --- backup.sh | 10 ++++++---- entrypoint.sh | 13 +++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/backup.sh b/backup.sh index 053b164..50d20ba 100644 --- a/backup.sh +++ b/backup.sh @@ -1,8 +1,10 @@ #!/bin/sh -if [ ! -d $(dirname "$BACKUP_FILE") ] -then - mkdir -p $(dirname "$BACKUP_FILE") +# Check if db file is accessible and exit otherwise +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 if [ $TIMESTAMP = true ] @@ -23,4 +25,4 @@ fi if [ ! -z $DELETE_AFTER ] && [ $DELETE_AFTER -gt 0 ] then find $(dirname "$BACKUP_FILE") -name "$(basename "$BACKUP_FILE")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \; -fi \ No newline at end of file +fi diff --git a/entrypoint.sh b/entrypoint.sh index 7676ea4..17148ce 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,13 @@ BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh" +# Preparation +if [ ! -d $(dirname "$BACKUP_FILE") ] +then + mkdir -p $(dirname "$BACKUP_FILE") + chown $UID:$GID $(dirname "$BACKUP_FILE") +fi + # 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" @@ -35,11 +42,5 @@ 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