connect-plug-zui-store 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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" 2> /dev/null; true
  20. lprint "Everything seems to be in place now... Exit connection the initiate the daemonizing voting"
  21. lprint "ZUI-STORE: $(ls -a "${ZUI_STORE}")"
  22. if [ -s "${ZUI_STORE}/.install.hook.service" ]; then
  23. if [ "$(cat "${ZUI_STORE}/.install.hook.service")" == "enable" ]; then
  24. lprint "ZUI will be enabled. Disable ${SNAP_NAME}."
  25. else
  26. lprint "ZUI won't be enabled. Keep ${SNAP_NAME} enabled."
  27. fi
  28. else
  29. lprint "The service file for ZUI is missing. Keep ${SNAP_NAME} enabled."
  30. fi
  31. exit 1
  32. else
  33. lprint "Plug/slot = zui-store is connected, but «${ZUI_STORE}» is missing... WHY! 🤷"
  34. fi
  35. else
  36. lprint "ZUI-store is NOT connected, but why did we end up here then??"
  37. fi
  38. #lprint "Connected ZUI (from: z2m)"