feat: support start the container as non-root user (close #45, close #47)

This commit is contained in:
ttionya
2022-06-30 23:30:51 +08:00
parent 44da441de0
commit c24263dd25
3 changed files with 9 additions and 9 deletions
+3 -1
View File
@@ -7,6 +7,8 @@ LABEL "repository"="https://github.com/ttionya/vaultwarden-backup" \
COPY scripts/*.sh /app/ COPY scripts/*.sh /app/
RUN chmod +x /app/*.sh \ RUN chmod +x /app/*.sh \
&& apk add --no-cache bash sqlite p7zip heirloom-mailx tzdata && apk add --no-cache bash heirloom-mailx p7zip sqlite supercronic tzdata \
&& ln -sf /tmp/localtime /etc/localtime \
&& mkdir -m 777 /bitwarden
ENTRYPOINT ["/app/entrypoint.sh"] ENTRYPOINT ["/app/entrypoint.sh"]
+5 -8
View File
@@ -37,16 +37,13 @@ if [[ "$1" == "restore" ]]; then
fi fi
function configure_timezone() { function configure_timezone() {
if [[ ! -f /etc/localtime || ! -f /etc/timezone ]]; then ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /tmp/localtime
cp -f "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
echo "${TIMEZONE}" > /etc/timezone
fi
} }
function configure_cron() { function configure_cron() {
local FIND_CRON_COUNT=$(crontab -l | grep -c 'backup.sh') local FIND_CRON_COUNT="$(grep -c 'backup.sh' "${CRON_CONFIG_FILE}" 2> /dev/null)"
if [[ ${FIND_CRON_COUNT} -eq 0 ]]; then if [[ "${FIND_CRON_COUNT}" -eq 0 ]]; then
echo "${CRON} bash /app/backup.sh > /dev/stdout" >> /etc/crontabs/root echo "${CRON} bash /app/backup.sh" >> "${CRON_CONFIG_FILE}"
fi fi
} }
@@ -56,4 +53,4 @@ configure_timezone
configure_cron configure_cron
# foreground run crond # foreground run crond
crond -l 2 -f supercronic -passthrough-logs -quiet "${CRON_CONFIG_FILE}"
+1
View File
@@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
ENV_FILE="/.env" ENV_FILE="/.env"
CRON_CONFIG_FILE="${HOME}/crontabs"
BACKUP_DIR="/bitwarden/backup" BACKUP_DIR="/bitwarden/backup"
RESTORE_DIR="/bitwarden/restore" RESTORE_DIR="/bitwarden/restore"
RESTORE_EXTRACT_DIR="/bitwarden/extract" RESTORE_EXTRACT_DIR="/bitwarden/extract"