configure 863 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. exec >> $SNAP_COMMON/hook.log 2>&1
  3. echo "$(date '+%Y-%m-%d %H:%M:%S') $0: Entering hook"
  4. # read wekan config
  5. . $SNAP/bin/config
  6. # settings were altered by user, safest way to get them applied is to restart service
  7. # first check if caddy service is enabled
  8. value=$(snapctl get caddy-enabled)
  9. if [ "$value" = "true" ]; then
  10. # update caddy file
  11. bind_port=$(snapctl get caddy-bind-port)
  12. port=$(snapctl get port)
  13. [ "x" != "x${bind_port}" ] && sed -i 's|proxy / localhost:.* {|proxy / localhost:'"${bind_port}"' {|g' $SNAP_COMMON/Caddyfile
  14. [ "x" != "x$port" ] && sed -i 's|http://:.*|http://:'"${port}"'|g' $SNAP_COMMON/Caddyfile
  15. snapctl start caddy-service 2>&1 || true
  16. else
  17. snapctl stop caddy-service 2>&1 || true
  18. fi
  19. # restart mongo and wekan service
  20. snapctl restart mongodb 2>&1 || true
  21. snapctl restart wekan 2>&1 || true