#!/usr/bin/env bash export DAEMONIZED=1 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 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" if [[ ! -d "${ZUI_STORE}/.z2m-logs" ]]; then mkdir "${ZUI_STORE}/.z2m-logs" fi mv -f "${ZUI_STORE}/zwave"*.{log,json} "${ZUI_STORE}/.z2m-logs" 2> /dev/null; true 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}." 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 exit 1 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)"