|
@@ -20,39 +20,29 @@ if ! snapctl is-connected raw-usb; then
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
-export USB_PATH=$(snapctl get usb-path)
|
|
|
+export NETWORK_KEY=$(snapctl get network.key)
|
|
|
+
|
|
|
+if [ -f "${SNAP_DATA}/settings.json" ]; then
|
|
|
+ SETTINGS_KEY=$(jq '.zwave.networkKey' -r ${SNAP_DATA}/settings.json)
|
|
|
+ if [ "${SETTINGS_KEY}" != "" ] && [ "${NETWORK_KEY}" != "${SETTINGS_KEY}" ]; then
|
|
|
+ snapctl set network.key="${SETTINGS_KEY}"
|
|
|
+ export NETWORK_KEY="${SETTINGS_KEY}"
|
|
|
+ fi
|
|
|
+fi
|
|
|
+
|
|
|
export SERVER_SSL=$(snapctl get server.ssl)
|
|
|
export SERVER_HOST=$(snapctl get server.host)
|
|
|
export SERVER_PORT=$(snapctl get server.port)
|
|
|
-
|
|
|
export SERVER_URL=$(snapctl get server.url)
|
|
|
-export SERVER_WS_URL=$(snapctl get server.url)
|
|
|
+export SERVER_WS_URL=$(snapctl get server.ws-url)
|
|
|
|
|
|
OPT_HELP=false
|
|
|
|
|
|
-if [ $(snapctl services "${SNAP_NAME}" | grep inactive | wc -l) -eq 0 -a ${OPT_HELP} = false ]; then
|
|
|
- echo ""
|
|
|
- for ARG in "${ARGV[@]}"; do
|
|
|
- shift
|
|
|
- if [ "${ARG}" = "--exec" ]; then
|
|
|
- lprint "Service already running, showing help text."
|
|
|
- lprint "Use: 'snap stop ${SNAP_NAME}' to stop the service and'"
|
|
|
- lprint "to execute the ${SNAP_NAME} manually"
|
|
|
- OPT_HELP=true
|
|
|
- continue
|
|
|
- fi
|
|
|
- set -- "$@" "${ARG}"
|
|
|
- done
|
|
|
+if [ "${1}" = "--help" ]; then
|
|
|
+ OPT_HELP=true
|
|
|
fi
|
|
|
|
|
|
-
|
|
|
-if [ ${OPT_HELP} = false ]; then
|
|
|
- if [ ! -c "${USB_PATH}" ]; then
|
|
|
- lprint "usb-path (${USB_PATH}) does not exist, or is not a Character Device."
|
|
|
- lprint "See: snap get ${SNAP_NAME} -d usb-path"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
-else
|
|
|
+if [ ${OPT_HELP} = true ]; then
|
|
|
echo "Zwavejs2mqtt ($ ($ 1 --version))"
|
|
|
echo ""
|
|
|
echo "IMPORTANT! The DAEMON/SERVICE is disabled by default after installation."
|
|
@@ -63,7 +53,7 @@ else
|
|
|
echo "But first set your configuration as descrived below"
|
|
|
echo ""
|
|
|
echo "Base configuration values:"
|
|
|
- echo "- usb-path: $(snapctl get "usb-path")"
|
|
|
+ echo "- network.key: $(snapctl get network.key)"
|
|
|
echo "Server configuration values: $(snapctl get server -d)"
|
|
|
echo ""
|
|
|
echo "- server.ssl: Use secure communication"
|
|
@@ -75,7 +65,7 @@ else
|
|
|
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 "Also see 'snap info ${SNAP_NAME}' for information about secure devices."
|
|
|
+ echo "Also see 'snap info ${SNAP_NAME}'."
|
|
|
echo ""
|
|
|
echo "Follow the log with"
|
|
|
echo "$ snap logs ${SNAP_NAME} -f"
|