forked from ttionya/vaultwarden-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
66 lines (48 loc) · 1.21 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
. /app/includes.sh
# rclone command
if [[ "$1" == "rclone" ]]; then
$*
exit 0
fi
# mail test
if [[ "$1" == "mail" ]]; then
export_env_file
init_env_mail
MAIL_SMTP_ENABLE="TRUE"
MAIL_DEBUG="TRUE"
if [[ -n "$2" ]]; then
MAIL_TO="$2"
fi
send_mail "vaultwarden Backup Test" "Your SMTP looks configured correctly."
exit 0
fi
# restore
if [[ "$1" == "restore" ]]; then
. /app/restore.sh
shift
restore $*
exit 0
fi
function configure_timezone() {
ln -sf "/usr/share/zoneinfo/${TIMEZONE}" "${LOCALTIME_FILE}"
}
function configure_cron() {
local FIND_CRON_COUNT="$(grep -c 'backup.sh' "${CRON_CONFIG_FILE}" 2> /dev/null)"
if [[ "${FIND_CRON_COUNT}" -eq 0 ]]; then
echo "${CRON} bash /app/backup.sh" >> "${CRON_CONFIG_FILE}"
fi
}
init_env
check_rclone_connection
configure_postgresql
configure_timezone
configure_cron
# backup manually
if [[ "$1" == "backup" ]]; then
color yellow "Manually triggering a backup will only execute the backup script once, and the container will exit upon completion."
bash "/app/backup.sh"
exit 0
fi
# foreground run crond
exec supercronic -passthrough-logs -quiet "${CRON_CONFIG_FILE}"