#!/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" 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)"