-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
93 lines (76 loc) · 2.21 KB
/
entrypoint.sh
File metadata and controls
93 lines (76 loc) · 2.21 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
set -eo pipefail
shopt -s nullglob
# logging functions
pbs_log() {
local type="$1"; shift
printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "$type" "$*"
}
pbs_note() {
pbs_log Note "$@"
}
pbs_warn() {
pbs_log Warn "$@" >&2
}
pbs_error() {
pbs_log ERROR "$@" >&2
exit 1
}
# Verify that the minimally required password settings are set for new databases.
docker_verify_minimum_env() {
if [ -z "$ADMIN_PASSWORD" ]; then
pbs_error $'Password option is not specified\n\tYou need to specify one of ADMIN_PASSWORD'
fi
}
# Loads various settings that are used elsewhere in the script
docker_setup_env() {
declare -g USERS_ALREADY_EXISTS
if [ -f "/etc/proxmox-backup/user.cfg" ]; then
USERS_ALREADY_EXISTS='true'
fi
}
docker_setup_pbs() {
#Set pbs user
proxmox-backup-manager user update root@pam --enable 0
proxmox-backup-manager user create admin@pbs
proxmox-backup-manager user update admin@pbs --password $ADMIN_PASSWORD
proxmox-backup-manager acl update / Admin --auth-id admin@pbs
#Set pbs default store
#proxmox-backup-manager datastore create Store1 /backup/store1
}
chown -R backup:backup /etc/proxmox-backup
chown -R backup:backup /var/log/proxmox-backup
chown -R backup:backup /var/lib/proxmox-backup
chown -R backup:backup /run/proxmox-backup
chmod -R 700 /etc/proxmox-backup
RELAY_HOST=${RELAY_HOST:-ext.home.local}
sed -i "s/RELAY_HOST/$RELAY_HOST/" /etc/postfix/main.cf
PBS_ENTERPRISE=${PBS_ENTERPRISE:-no}
if [ "$PBS_ENTERPRISE" != "yes" ]; then
rm -f /etc/apt/sources.list.d/pbs-enterprise.list
fi
docker_verify_minimum_env
echo "Starting Rsyslogd..."
rsyslogd
# Start api first in background
echo -n "Starting Proxmox backup API..."
/usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-api &
while true; do
if [ ! -f /run/proxmox-backup/api.pid ]; then
echo -n "..."
sleep 3
else
break
fi
done
#sleep 10
echo "OK"
docker_setup_env
# there's no user setup, so it needs to be initialized
if [ -z "$USERS_ALREADY_EXISTS" ]; then
docker_setup_pbs
fi
echo "Starting Postfix..."
/etc/init.d/postfix start || ok=1
echo "Running PBS..."
exec gosu backup /usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-proxy "$@"