env-wrapper 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/usr/bin/env bash
  2. source $SNAP/helper/functions
  3. # WITH S0+n NETWORK KEY IS NOT USED ANYMORE
  4. #export NETWORK_KEY=$(snapctl get network.key)
  5. # SETTINGS_KEY=$(same_network_key "${NETWORK_KEY}")
  6. # if [ $? -ne 0 ]; then
  7. # snapctl set network.key="${SETTINGS_KEY}"
  8. # export NETWORK_KEY="${SETTINGS_KEY}"
  9. # fi
  10. OPT_HELP=false
  11. if [ "${1}" = "--help" ]; then
  12. OPT_HELP=true
  13. fi
  14. if [ ${OPT_HELP} = true ]; then
  15. plugs_connected
  16. if [ $? -ne 0 ]; then
  17. echo ""
  18. echo "NOTE! NOTE! NOTE!"
  19. echo ""
  20. fi
  21. echo "${SNAP_NAME} - $(yq eval '.version' "${SNAP}/meta/snap.yaml")"
  22. echo ""
  23. echo "IMPORTANT! The DAEMON/SERVICE is disabled by default after installation."
  24. echo "You have to manually 'daemonize' it with executing the command"
  25. echo ""
  26. echo "$ ${SNAP_NAME}.enable"
  27. echo ""
  28. echo "Set your configuration as descrived below"
  29. echo ""
  30. # echo "Base configuration values:"
  31. # echo "- network.key: $(snapctl get network.key)"
  32. echo "Server configuration values: $(snapctl get server -d)"
  33. echo ""
  34. echo "- server.ssl: Use secure communication"
  35. echo "- server.host: IP address to bind to, e.g 127.0.0.1"
  36. echo "- server.port: Port to reach the web interface"
  37. echo ""
  38. echo "Session configuration values: $(snapctl get session -d)"
  39. echo ""
  40. echo "- session.secret: Used as secret for session. If not provided a default one is used."
  41. echo "- session.cookie-secure: Set the cookie secure option. See: https://github.com/expressjs/session#cookiesecure"
  42. echo ""
  43. echo "Session configuration values: $(snapctl get mqtt -d)"
  44. echo ""
  45. echo "- mqtt.name: The name used as client name when connecting to the mqtt server."
  46. echo ""
  47. echo "Set options with: $ snap set ${SNAP_NAME} param=key"
  48. echo "For example: $ snap set ${SNAP_NAME} server.host=0.0.0.0"
  49. echo ""
  50. echo "Other settings can be set in the UI after start."
  51. echo ""
  52. echo "If you have turned OFF «log to file», follow the log(s) with"
  53. echo " $ sudo snap logs ${SNAP_NAME} -f"
  54. echo ""
  55. echo "OR if you have turned ON «log to file», tail the logs with"
  56. echo " $ tail -f ${SNAP_DATA}/*.log"
  57. echo ""
  58. echo "Other commands"
  59. echo "Disable the daemon: $ ${SNAP_NAME}.disable"
  60. echo "Restart the daemon: $ ${SNAP_NAME}.restart"
  61. echo ""
  62. echo "Info on the serial-port plug:"
  63. echo " This plug requires the experimental hotplug feature in snapd."
  64. echo " Enable it with"
  65. echo " $ sudo snap set system experimental.hotplug=true"
  66. echo ""
  67. echo " And restart snapd with:"
  68. echo " $ sudo systemctl restart snapd"
  69. echo ""
  70. echo " Now list available serial slots with:"
  71. echo " $ sudo snap iterface serial-port"
  72. echo ""
  73. echo " And connect it to ${SNAP_NAME} with:"
  74. echo " $ sudo snap connect ${SNAP_NAME}:serial-port <slot name>"
  75. exit 0
  76. fi
  77. require_root
  78. plugs_connected
  79. if [ $? -ne 0 ]; then
  80. exit 1
  81. fi
  82. # Not needed anymore as of ZWAVEJS_EXTERNAL_CONFIG?
  83. # ensure_zwavejs_config
  84. export SERVER_HOST=$(snapctl get server.host)
  85. export SERVER_PORT=$(snapctl get server.port)
  86. export HOST="${SERVER_HOST}"
  87. export PORT="${SERVER_PORT}"
  88. export SERVER_SSL=$(snapctl get server.ssl)
  89. export HTTPS="${SERVER_SSL}"
  90. export FORCE_DISABLE_SSL=$(snapctl get server.force-disable-ssl)
  91. if [ "${FORCE_DISABLE_SSL}" != true ]; then
  92. unset FORCE_DISABLE_SSL
  93. fi
  94. export USE_SECURE_COOKIE=$(snapctl get session.cookie-secure)
  95. if [ "${HTTPS}" != true ] || [ "${FORCE_DISABLE_SSL}" == true ]; then
  96. unset HTTPS
  97. unset SERVER_SSL
  98. unset USE_SECURE_COOKIE
  99. elif [ "${USE_SECURE_COOKIE}" != true ]; then
  100. unset USE_SECURE_COOKIE
  101. fi
  102. export SESSION_SECRET=$(snapctl get session.secret)
  103. export MQTT_NAME=$(snapctl get mqtt.name)
  104. if [ -z "${MQTT_NAME}" ]; then
  105. unset MQTT_NAME
  106. fi
  107. export GIT_DIR="${SNAP}/lib/zwavejs2mqtt/.git"
  108. [ "$(basename "${1}")" == "yarn" ] && cd "${SNAP}/lib/zwavejs2mqtt" && exec "${@}" || exec "${@}"