configure 1.0 KB

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