Browse Source

Update more logging

Joachim M. Giæver 1 year ago
parent
commit
7babd28090
2 changed files with 26 additions and 18 deletions
  1. 17 17
      src/bin/cpy-2-zui
  2. 9 1
      src/hooks/connect-plug-zui-store

+ 17 - 17
src/bin/cpy-2-zui

@@ -4,23 +4,23 @@ source $SNAP/helper/functions
 
 require_root
 
-cpy_2_zui
+#cpy_2_zui
 
-if [ $? -ne 0 ]; then
-	echo "Failed, exiting."
-	exit 1
-fi
+#if [ $? -ne 0 ]; then
+#	echo "Failed, exiting."
+#	exit 1
+#fi
 
-if snapctl is-connected serial-port; then
-	lprint "Serial-port is connected, which require manual configuration in zwave-js-ui"
-elif [ -s "${SNAP_COMMON}/zui-store/.hook.install" ]; then
-	if [ "$(cat "${SNAP_COMMON}/.hook.install")" == "enable" ]; then
-		snapctl stop "${SNAP_NAME}" && snapctl stop --disable "${SNAP_NAME}"
-		lprint "Disabled ${SNAP_NAME} and zwave-js-ui should be enabled."
-	else
-		lprint "ZUI is set to be disabled, and wont disable ${SNAP_NAME}.".
-	fi
-else
-	lprint "Wont disable Z2M"
-fi
+#if snapctl is-connected serial-port; then
+#	lprint "Serial-port is connected, which require manual configuration in zwave-js-ui"
+#elif [ -s "${SNAP_COMMON}/zui-store/.hook.install" ]; then
+#	if [ "$(cat "${SNAP_COMMON}/.hook.install")" == "enable" ]; then
+#		snapctl stop "${SNAP_NAME}" && snapctl stop --disable "${SNAP_NAME}"
+#		lprint "Disabled ${SNAP_NAME} and zwave-js-ui should be enabled."
+#	else
+#		lprint "ZUI is set to be disabled, and wont disable ${SNAP_NAME}.".
+#	fi
+#else
+#	lprint "Wont disable Z2M"
+#fi
 

+ 9 - 1
src/hooks/connect-plug-zui-store

@@ -6,9 +6,17 @@ source $SNAP/helper/functions
 #$SNAP/bin/cpy-2-zui
 
 if snapctl is-connected zui-store; then
+	ZUI_STORE="${SNAP_COMMON}/zui-store"
 	lprint "ZUI-store is connected"
+	if [ "$(ls "${ZUI_STORE}" | wc -l)" -ne 0 ]; then
+		lprint "ZUI-store (${ZUI_STORE}) is not empty: $(ls "${ZUI_STORE}")"
+		exit 1
+	else
+		lprint "ZUI-store is empty, copying over data: $(ls "${SNAP_DATA}")"
+	fi
 else
-	lprint "ZUI-store is NOT connected"
+	lprint "ZUI-store is NOT connected, but why did we end up here then??"
 fi
 
 #lprint "Connected ZUI (from: z2m)"
+#