summaryrefslogtreecommitdiffstats
path: root/snap/hooks/configure
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-02-22 02:17:52 +0200
committerLauri Ojansivu <x@xet7.org>2018-02-22 02:17:52 +0200
commit7498dba32c8fbf460e04af49d5fb32dc5e63ed8b (patch)
tree19d7cbfa45e4de37142e6a2dcede722b3f09a89d /snap/hooks/configure
parent26f66f3cf05d3ab3dd633d02399cea5aa5a99c00 (diff)
parentd374cd2f813e5e88b0e10b6fe851565b36e5ab0a (diff)
downloadwekan-7498dba32c8fbf460e04af49d5fb32dc5e63ed8b.tar.gz
wekan-7498dba32c8fbf460e04af49d5fb32dc5e63ed8b.tar.bz2
wekan-7498dba32c8fbf460e04af49d5fb32dc5e63ed8b.zip
Merge branch 'kubiko-devel' into devel
Diffstat (limited to 'snap/hooks/configure')
-rwxr-xr-xsnap/hooks/configure44
1 files changed, 19 insertions, 25 deletions
diff --git a/snap/hooks/configure b/snap/hooks/configure
index 1e2b0ec7..5d121e15 100755
--- a/snap/hooks/configure
+++ b/snap/hooks/configure
@@ -1,32 +1,26 @@
#!/bin/bash
+exec >> $SNAP_COMMON/hook.log 2>&1
+echo "$(date '+%Y-%m-%d %H:%M:%S') $0: Entering hook"
+
+set -x
+
# read wekan config
. $SNAP/bin/config
-# create run dir, we're going to use it for unix socket
-mkdir -p $SNAP_DATA/share
-mkdir -p $SNAP_DATA/shared
-
# 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 --enable ${SNAP_NAME}.caddy 2>&1 || true
+else
+ snapctl stop --disable ${SNAP_NAME}.caddy 2>&1 || true
+fi
-# TODO: remove this workaround once it's not needed
-# for the moment we can't read settings outside of the hook,
-# so store all settings in helpper script which is then picked by main wrapper
-echo -e "#!/bin/sh\n" > $SETTINGS_FILE
-for key in ${keys[@]}
-do
- # snappy is picky about key syntax, using mapping
- MAP_KEY="KEY_$key"
- if value=$(snapctl get ${!MAP_KEY}); then
- echo "export $key='$value'" >> $SETTINGS_FILE
- elif [ -d "${!key}" ]; then
- # store back value from SETTINGS_FILE
- echo "export $key='${!key}'" >> $SETTINGS_FILE
- fi
-done
-
-# set file executable
-chmod 755 $SETTINGS_FILE
-# we can't use snapctl to restart service, may be one day ....
-
-echo "Setting has been updated, restart service."
+# restart all services
+snapctl restart ${SNAP_NAME} 2>&1 || true