connect-plug-zui-store 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. export DAEMONIZED=1
  3. source $SNAP/helper/functions
  4. #$SNAP/bin/cpy-2-zui
  5. if snapctl is-connected zui-store; then
  6. ZUI_STORE="${SNAP_COMMON}/zui-store"
  7. lprint "ZUI-store is connected"
  8. if [ "$(ls "${ZUI_STORE}" | wc -l)" -ne 0 ]; then
  9. lprint "ZUI-store (${ZUI_STORE}) is not empty: $(ls "${ZUI_STORE}")"
  10. exit 1
  11. elif [ -d "${ZUI_STORE}" ]; then
  12. lprint "ZUI-store is empty, copying over data: $(ls "${SNAP_DATA}") to «${ZUI_STORE}»"
  13. cp -rf "${SNAP_DATA}/"* "${ZUI_STORE}"
  14. rm -rf "${ZUI_STORE}/.ext-config"
  15. mv -f "${ZUI_STORE}/logs" "${ZUI_STORE}/.z2m-logs"
  16. if [[ ! -d "${ZUI_STORE}/.z2m-logs" ]]; then
  17. mkdir "${ZUI_STORE}/.z2m-logs"
  18. fi
  19. mv -f "${ZUI_STORE}/zwave"*.{log,json} "${ZUI_STORE}/.z2m-logs"
  20. lprint "Everything seems to be in place now... Exit connection the initiate the daemonizing voting"
  21. exit 1
  22. else
  23. lprint "Plug/slot = zui-store is connected, but «${ZUI_STORE}» is missing... WHY! 🤷"
  24. fi
  25. else
  26. lprint "ZUI-store is NOT connected, but why did we end up here then??"
  27. fi
  28. #lprint "Connected ZUI (from: z2m)"