configure 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. exec >> $SNAP_DATA/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. snapctl restart ${SNAP_NAME}.caddy 2>&1 || true
  18. else
  19. snapctl stop --disable ${SNAP_NAME}.caddy 2>&1 || true
  20. fi
  21. value=$(snapctl get disable-mongodb)
  22. if [ "$value" = "true" ]; then
  23. snapctl stop --disable ${SNAP_NAME}.mongodb 2>&1 || true
  24. else
  25. snapctl start --enable ${SNAP_NAME}.mongodb 2>&1 || true
  26. snapctl restart ${SNAP_NAME}.mongodb 2>&1 || true
  27. fi
  28. # restart all services
  29. snapctl restart ${SNAP_NAME}.wekan 2>&1 || true