Browse Source

Remove debug flag and fix issue with deamon

Joachim M. Giæver 3 years ago
parent
commit
97ca7e2149
2 changed files with 16 additions and 7 deletions
  1. 1 1
      snap/snapcraft.yaml
  2. 15 6
      src/bin/env-wrapper

+ 1 - 1
snap/snapcraft.yaml

@@ -35,7 +35,7 @@ apps:
       - network-bind
       - raw-usb
   exec:
-    command: usr/local/bin/ozwdaemon
+    command: usr/local/bin/ozwdaemon --exec
     command-chain:
       - bin/env-wrapper
     plugs:

+ 15 - 6
src/bin/env-wrapper

@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-set -ex
+set -e
 
 OZW_LIB=$(dirname $(find "${SNAP}/usr/local" -name libopenzwave.so -print -quit))
 export LD_LIBRARY_PATH="${OZW_LIB}:${LD_LIBRARY_PATH}"
@@ -50,14 +50,23 @@ for ((i = 0; i < $#; i++)); do
     fi
 done
 
+
 if [ $(snapctl services ozwdaemon | grep inactive | wc -l) -eq 0 -a ${OPT_HELP} = false ]; then
-    lprint "Service already running, showing help text."
-    lprint "Use: 'snap stop ${SNAP_NAME}' to stop the service and'"
-    lprint "to execute the ozwdaemon manually"
     echo ""
-    OPT_HELP=true
+    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 ozwdaemon manually"
+            OPT_HELP=true
+            continue
+        fi
+        set -- "$@" "${ARG}"
+    done
 fi
 
+
 if [ ${OPT_HELP} = false ]; then
     if [ ! -c "${USB_PATH}" ]; then 
         lprint "usb-path (${USB_PATH}) does not exist,"
@@ -119,7 +128,7 @@ if [ ${OPT_HELP} = false ]; then
 
     set -- "$@" "${OZW_ARGS[@]}"
 else
-    echo "QT OpenZWave Remote Daemon ($($SNAP/usr/local/bin/ozwdaemon --version))"
+    echo "QT OpenZWave Remote Daemon ($($1 --version))"
     echo ""
     echo "- usb-path:               $(snapctl get "usb-path")"
     echo "- stop-on-failure:        $(snapctl get "stop-on-failure")"