Browse Source

Add mqtt.name and small edits

Joachim M. Giæver 3 years ago
parent
commit
0df191990d
3 changed files with 21 additions and 3 deletions
  1. 14 1
      src/helper/env-wrapper
  2. 1 2
      src/helper/functions
  3. 6 0
      src/hooks/configure

+ 14 - 1
src/helper/env-wrapper

@@ -54,13 +54,20 @@ if [ ${OPT_HELP} = true ]; then
     echo ""
     echo ""
     echo "Session configuration values: $(snapctl get session -d)"
     echo "Session configuration values: $(snapctl get session -d)"
     echo ""
     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 "Set options with:         $ snap set ${SNAP_NAME} param=key"
     echo "For example:              $ snap set ${SNAP_NAME} server.host=0.0.0.0"
     echo "For example:              $ snap set ${SNAP_NAME} server.host=0.0.0.0"
     echo ""
     echo ""
     echo "Other settings can be set in the UI after start."
     echo "Other settings can be set in the UI after start."
     echo ""
     echo ""
     echo "Follow the log with"
     echo "Follow the log with"
-    echo "$ snap logs ${SNAP_NAME} -f"
+    echo "$ sudo snap logs ${SNAP_NAME} -f"
     echo ""
     echo ""
     echo "Other commands"
     echo "Other commands"
     echo "Disable the daemon:       $ ${SNAP_NAME}.disable"
     echo "Disable the daemon:       $ ${SNAP_NAME}.disable"
@@ -97,6 +104,12 @@ elif [ "${USE_SECURE_COOKIE}" != true ]; then
     unset USE_SECURE_COOKIE
     unset USE_SECURE_COOKIE
 fi
 fi
 
 
+export MQTT_NAME=$(snapctl get mqtt.name)
+
+if [ -z "${MQTT_NAME}" ]; then
+    unset MQTT_NAME
+fi
+
 export HOST="${SERVER_HOST}"
 export HOST="${SERVER_HOST}"
 export PORT="${SERVER_PORT}"
 export PORT="${SERVER_PORT}"
 
 

+ 1 - 2
src/helper/functions

@@ -97,8 +97,6 @@ function testnset_config {
             exit 1
             exit 1
         fi
         fi
         return 0
         return 0
-    else
-        logger "${SNAP_NAME}: ${1} has ${RES}, leaving as is"
     fi
     fi
     return 0
     return 0
 }
 }
@@ -111,4 +109,5 @@ function test_default_config {
     testnset_config "server.host" "localhost"
     testnset_config "server.host" "localhost"
     testnset_config "server.port" 8091
     testnset_config "server.port" 8091
 
 
+    testnset_config "mqtt.name" ""
 }
 }

+ 6 - 0
src/hooks/configure

@@ -5,6 +5,7 @@ source $SNAP/helper/functions
 
 
 SERVER_SSL=$(snapctl get server.ssl)
 SERVER_SSL=$(snapctl get server.ssl)
 SERVER_PORT=$(snapctl get server.port)
 SERVER_PORT=$(snapctl get server.port)
+COOKIE_SECURE=$(snapctl get sessio.cookie-secure)
 
 
 if [ $(echo "${SERVER_PORT}" | grep -E "^\-?[0-9]+$") = "" ]; then
 if [ $(echo "${SERVER_PORT}" | grep -E "^\-?[0-9]+$") = "" ]; then
     echo "!! server.port must be numeric, got ${SERVER_PORT}" >&2
     echo "!! server.port must be numeric, got ${SERVER_PORT}" >&2
@@ -16,6 +17,11 @@ if [ ${SERVER_SSL} != true -a ${SERVER_SSL} != false ]; then
     exit 1
     exit 1
 fi
 fi
 
 
+if [ ${COOKIE_SECURE} != true -a ${COOKIE_SECURE} != false ]; then
+    echo "!! session.cookie-secure must be boolean value" >&2
+    exit 1
+fi
+
 NETWORK_KEY=$(snapctl get network.key)
 NETWORK_KEY=$(snapctl get network.key)
 
 
 if [ ! -f "${SNAP_DATA}/settings.json" ]; then
 if [ ! -f "${SNAP_DATA}/settings.json" ]; then