123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #!/usr/bin/env bash
- source $SNAP/helper/functions
- if [ -z "${DAEMONIZED}" ]; then
- DAEMONIZED=0
- fi
- function lprint {
- if [ ${DAEMONIZED} -eq 0 ]; then
- echo ${1}
- else
- logger "${SNAP_NAME}: ${1}"
- fi
- }
- # WITH S0+n NETWORK KEY IS NOT USED ANYMORE
- #export NETWORK_KEY=$(snapctl get network.key)
- # SETTINGS_KEY=$(same_network_key "${NETWORK_KEY}")
- # if [ $? -ne 0 ]; then
- # snapctl set network.key="${SETTINGS_KEY}"
- # export NETWORK_KEY="${SETTINGS_KEY}"
- # fi
- OPT_HELP=false
- if [ "${1}" = "--help" ]; then
- OPT_HELP=true
- fi
- if [ ${OPT_HELP} = true ]; then
- plugs_connected
- if [ $? -ne 0 ]; then
- echo ""
- echo "NOTE! NOTE! NOTE!"
- echo ""
- fi
- echo "${SNAP_NAME} - $(yq eval '.version' "${SNAP}/meta/snap.yaml")"
- echo ""
- echo "IMPORTANT! The DAEMON/SERVICE is disabled by default after installation."
- echo "You have to manually 'daemonize' it with executing the command"
- echo ""
- echo "$ ${SNAP_NAME}.enable"
- echo ""
- echo "Set your configuration as descrived below"
- echo ""
- # echo "Base configuration values:"
- # echo "- network.key: $(snapctl get network.key)"
- echo "Server configuration values: $(snapctl get server -d)"
- echo ""
- echo "- server.ssl: Use secure communication"
- echo "- server.host: IP address to bind to, e.g 127.0.0.1"
- echo "- server.port: Port to reach the web interface"
- echo ""
- echo "Session configuration values: $(snapctl get session -d)"
- echo ""
- echo "- session.secret: Used as secret for session. If not provided a default one is used."
- echo "- session.cookie-secure: Set the cookie secure option. See: https://github.com/expressjs/session#cookiesecure"
- echo ""
- echo "Session configuration values: $(snapctl get mqtt -d)"
- echo ""
- echo "- mqtt.name: The name used as client name when connecting to the mqtt server."
- echo ""
- echo "Set options with: $ snap set ${SNAP_NAME} param=key"
- echo "For example: $ snap set ${SNAP_NAME} server.host=0.0.0.0"
- echo ""
- echo "Other settings can be set in the UI after start."
- echo ""
- echo "If you have turned OFF «log to file», follow the log(s) with"
- echo " $ sudo snap logs ${SNAP_NAME} -f"
- echo ""
- echo "OR if you have turned ON «log to file», tail the logs with"
- echo " $ tail -f ${SNAP_DATA}/*.log"
- echo ""
- echo "Other commands"
- echo "Disable the daemon: $ ${SNAP_NAME}.disable"
- echo "Restart the daemon: $ ${SNAP_NAME}.restart"
- echo ""
- echo "Info on the serial-port plug:"
- echo " This plug requires the experimental hotplug feature in snapd."
- echo " Enable it with"
- echo " $ sudo snap set system experimental.hotplug=true"
- echo ""
- echo " And restart snapd with:"
- echo " $ sudo systemctl restart snapd"
- echo ""
- echo " Now list available serial slots with:"
- echo " $ sudo snap iterface serial-port"
- echo ""
- echo " And connect it to ${SNAP_NAME} with:"
- echo " $ sudo snap connect ${SNAP_NAME}:serial-port <slot name>"
- exit 0
- fi
- require_root
- plugs_connected
- if [ $? -ne 0 ]; then
- exit 1
- fi
- # Not needed anymore as of ZWAVEJS_EXTERNAL_CONFIG?
- # ensure_zwavejs_config
- export SERVER_HOST=$(snapctl get server.host)
- export SERVER_PORT=$(snapctl get server.port)
- export HOST="${SERVER_HOST}"
- export PORT="${SERVER_PORT}"
- export SERVER_SSL=$(snapctl get server.ssl)
- export HTTPS="${SERVER_SSL}"
- export FORCE_DISABLE_SSL=$(snapctl get server.force-disable-ssl)
- if [ "${FORCE_DISABLE_SSL}" != true ]; then
- unset FORCE_DISABLE_SSL
- fi
- export USE_SECURE_COOKIE=$(snapctl get session.cookie-secure)
- if [ "${HTTPS}" != true ] || [ "${FORCE_DISABLE_SSL}" == true ]; then
- unset HTTPS
- unset SERVER_SSL
- unset USE_SECURE_COOKIE
- elif [ "${USE_SECURE_COOKIE}" != true ]; then
- unset USE_SECURE_COOKIE
- fi
- export SESSION_SECRET=$(snapctl get session.secret)
- export MQTT_NAME=$(snapctl get mqtt.name)
- if [ -z "${MQTT_NAME}" ]; then
- unset MQTT_NAME
- fi
- export GIT_DIR="${SNAP}/lib/zwavejs2mqtt/.git"
- [ "$(basename "${1}")" == "yarn" ] && cd "${SNAP}/lib/zwavejs2mqtt" && exec "${@}" || exec "${@}"
|