connect-plug-zui-store 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. if [ -s "${SNAP_COMMON}/.eol" ]; then
  7. lprint "Met EOL. ZUI «zwave-js-ui» should already be installed, configured and enabled on your system."
  8. exit 1
  9. fi
  10. ZUI_STORE="${SNAP_COMMON}/zui-store"
  11. lprint "ZUI-store is connected"
  12. if [ "$(ls "${ZUI_STORE}" | wc -l)" -ne 0 ]; then
  13. lprint "ZUI-store (${ZUI_STORE}) is not empty: $(ls "${ZUI_STORE}")"
  14. exit 1
  15. elif [ -d "${ZUI_STORE}" ]; then
  16. lprint "ZUI-store is empty, copying over data: $(ls "${SNAP_DATA}") to «${ZUI_STORE}»"
  17. cp -rf "${SNAP_DATA}/"* "${ZUI_STORE}"
  18. rm -rf "${ZUI_STORE}/.ext-config"
  19. mv -f "${ZUI_STORE}/logs" "${ZUI_STORE}/.z2m-logs"
  20. mv -f "${ZUI_STORE}/zwave"*.{log,json} "${ZUI_STORE}/.z2m-logs"
  21. lprint "Everything seems to be in place now... Exit connection the initiate the daemonizing voting"
  22. lprint "ZUI-STORE: $(ls -a "${ZUI_STORE}")"
  23. SERVICE_FILE="${ZUI_STORE}/.install.hook.service"
  24. if [ -s "${SERVICE_FILE}" ]; then
  25. if [ "$(cat "${SERVICE_FILE}")" == "enable" ]; then
  26. lprint "ZUI will be enabled. Disable ${SNAP_NAME}."
  27. touch "${SNAP_COMMON}/.eol"
  28. exit 1
  29. else
  30. lprint "ZUI won't be enabled. Keep ${SNAP_NAME} enabled."
  31. fi
  32. else
  33. lprint "The service file for ZUI (${SERVICE_FILE}) is missing. Keep ${SNAP_NAME} enabled."
  34. fi
  35. else
  36. lprint "Plug/slot = zui-store is connected, but «${ZUI_STORE}» is missing... WHY! 🤷"
  37. fi
  38. else
  39. lprint "ZUI-store is NOT connected, but why did we end up here then??"
  40. fi
  41. #lprint "Connected ZUI (from: z2m)"