blob: 15d68a19772640f009f2b32eb0aa7ab0dd55f5d0 (
plain)
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
|
#!/bin/bash
exec >> $SNAP_COMMON/hook.log 2>&1
echo "$(date '+%Y-%m-%d %H:%M:%S') $0: Entering hook"
# read wekan config
. $SNAP/bin/config
# settings were altered by user, safest way to get them applied is to restart service
# first check if caddy service is enabled
value=$(snapctl get caddy-enabled)
if [ "$value" = "true" ]; then
# update caddy file
bind_port=$(snapctl get caddy-bind-port)
port=$(snapctl get port)
[ "x" != "x${bind_port}" ] && sed -i 's|proxy / localhost:.* {|proxy / localhost:'"${bind_port}"' {|g' $SNAP_COMMON/Caddyfile
[ "x" != "x$port" ] && sed -i 's|http://:.*|http://:'"${port}"'|g' $SNAP_COMMON/Caddyfile
snapctl start caddy-service 2>&1 || true
else
snapctl stop caddy-service 2>&1 || true
fi
# restart mongo and wekan service
snapctl restart mongodb 2>&1 || true
snapctl restart wekan 2>&1 || true
|