#!/usr/bin/env bash export DAEMONIZED=1 source $SNAP/helper/functions #$SNAP/bin/cpy-2-zui if snapctl is-connected zui-store; then if [ -s "${SNAP_COMMON}/.eol" ]; then lprint "Met EOL. ZUI «zwave-js-ui» should already be installed, configured and enabled on your system." exit 1 fi 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 elif [ -d "${ZUI_STORE}" ]; then lprint "ZUI-store is empty, copying over data: $(ls "${SNAP_DATA}") to «${ZUI_STORE}»" cp -rf "${SNAP_DATA}/"* "${ZUI_STORE}" rm -rf "${ZUI_STORE}/.ext-config" mv -f "${ZUI_STORE}/logs" "${ZUI_STORE}/.z2m-logs" mv -f "${ZUI_STORE}/zwave"*.{log,json} "${ZUI_STORE}/.z2m-logs" lprint "Everything seems to be in place now... Exit connection the initiate the daemonizing voting" lprint "ZUI-STORE: $(ls -a "${ZUI_STORE}")" SERVICE_FILE="${ZUI_STORE}/.install.hook.service" if [ -s "${SERVICE_FILE}" ]; then if [ "$(cat "${SERVICE_FILE}")" == "enable" ]; then lprint "ZUI will be enabled. Disable ${SNAP_NAME}." touch "${SNAP_COMMON}/.eol" exit 1 else lprint "ZUI won't be enabled. Keep ${SNAP_NAME} enabled." fi else lprint "The service file for ZUI (${SERVICE_FILE}) is missing. Keep ${SNAP_NAME} enabled." fi else lprint "Plug/slot = zui-store is connected, but «${ZUI_STORE}» is missing... WHY! 🤷" fi else lprint "ZUI-store is NOT connected, but why did we end up here then??" fi #lprint "Connected ZUI (from: z2m)"