configure 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. set -e
  3. export DAEMONIZED=1
  4. source $SNAP/helper/functions
  5. SERVER_SSL=$(snapctl get server.ssl)
  6. SERVER_PORT=$(snapctl get server.port)
  7. COOKIE_SECURE=$(snapctl get sessio.cookie-secure)
  8. if [ $(echo "${SERVER_PORT}" | grep -E "^\-?[0-9]+$") = "" ]; then
  9. lprint "!! server.port must be numeric, got ${SERVER_PORT}" >&2
  10. exit 1
  11. fi
  12. if [ ${SERVER_SSL} != true -a ${SERVER_SSL} != false ]; then
  13. lprint "!! server.ssl must be boolean value" >&2
  14. exit 1
  15. fi
  16. if [ ${COOKIE_SECURE} != true -a ${COOKIE_SECURE} != false ]; then
  17. lprint "!! session.cookie-secure must be boolean value" >&2
  18. exit 1
  19. fi
  20. # AS WITH S0+n NETWORK_KEY is not used anymore
  21. # NETWORK_KEY=$(snapctl get network.key)
  22. #
  23. # if [ ! -f "${SNAP_DATA}/settings.json" ]; then
  24. # echo "{}" > ${SNAP_DATA}/settings.json
  25. # fi
  26. #
  27. # jq --arg networkKey "${NETWORK_KEY}" '.zwave.networkKey = $networkKey' $SNAP_DATA/settings.json > $SNAP_DATA/tmp.json
  28. # cat ${SNAP_DATA}/tmp.json > ${SNAP_DATA}/settings.json
  29. # rm ${SNAP_DATA}/tmp.json
  30. test_default_config
  31. RUNNING=$(snapctl services | grep "${SNAP_NAME}" | grep inactive | wc -l)
  32. if [ ${RUNNING} -eq 0 ]; then
  33. lprint "Restarting ${SNAP_NAME}"
  34. snapctl restart "${SNAP_NAME}"
  35. fi