generated from Start9Labs/hello-world-startos
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_entrypoint.sh
executable file
·67 lines (60 loc) · 2.26 KB
/
docker_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
67
#!/bin/sh
set -ea
_term() {
echo "Caught SIGTERM signal!"
kill -TERM "$dead_man_switch_web_process" 2>/dev/null
}
UI_TOR_ADDRESS="$(yq e '.tor-address' /root/start9/config.yaml)"
UI_LAN_ADDRESS="$(echo $UI_TOR_ADDRESS | sed 's/\.onion/\.local/')"
UI_PASSWORD="$(yq e '.password' /root/start9/config.yaml)"
SMTP_SERVER="$(yq e '.smtp.server' /root/start9/config.yaml)"
SMTP_PORT="$(yq e '.smtp.port' /root/start9/config.yaml)"
SMTP_USERNAME="$(yq e '.smtp.username' /root/start9/config.yaml)"
SMTP_PASSWORD="$(yq e '.smtp.password' /root/start9/config.yaml)"
EMAIL_FROM="$(yq e '.email.from' /root/start9/config.yaml)"
EMAIL_TO="$(yq e '.email.to' /root/start9/config.yaml)"
EMAIL_SUBJECT="$(yq e '.email.subject' /root/start9/config.yaml)"
EMAIL_SUBJECT_WARNING="$(yq e '.email.subject_warning' /root/start9/config.yaml)"
EMAIL_MESSAGE="$(yq e '.email.message' /root/start9/config.yaml)"
EMAIL_MESSAGE_WARNING="$(yq e '.email.message_warning' /root/start9/config.yaml)"
TIMER_DEAD_MAN_SWITCH="$(yq e '.timer.dead_man' /root/start9/config.yaml)"
TIMER_WARNING="$(yq e '.timer.warning' /root/start9/config.yaml)"
export UI_TOR_ADDRESS
export UI_LAN_ADDRESS
export UI_PASSWORD
export SMTP_SERVER
export SMTP_PORT
export SMTP_USERNAME
export SMTP_PASSWORD
export EMAIL_FROM
export EMAIL_TO
export EMAIL_SUBJECT
export EMAIL_SUBJECT_WARNING
export EMAIL_MESSAGE
export EMAIL_MESSAGE_WARNING
export TIMER_DEAD_MAN_SWITCH
export TIMER_WARNING
echo "Writing config file"
mkdir -p /root/.config/deadman
touch /root/.config/deadman/config.toml
{
echo "web_password = \"$UI_PASSWORD\""
echo "username = \"$SMTP_USERNAME\""
echo "password = \"$SMTP_PASSWORD\""
echo "smtp_server = \"$SMTP_SERVER\""
echo "smtp_port = $SMTP_PORT"
echo "from = \"$EMAIL_FROM\""
echo "to = \"$EMAIL_TO\""
echo "subject = \"$EMAIL_SUBJECT\""
echo "subject_warning = \"$EMAIL_SUBJECT_WARNING\""
echo "message = \"$EMAIL_MESSAGE\""
echo "message_warning = \"$EMAIL_MESSAGE_WARNING\""
echo "timer_dead_man = $TIMER_DEAD_MAN_SWITCH"
echo "timer_warning = $TIMER_WARNING"
} > /root/.config/deadman/config.toml
echo "All configuration done"
echo "Starting dead_man_switch_web"
dead_man_switch_web &
dead_man_switch_web_process=$!
trap _term TERM
wait $dead_man_switch_web_process