env-wrapper 4.2 KB

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