connect-plug-zui-store 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. SERVICE_FILE="${ZUI_STORE}/.install.hook.service"
  23. if [ -s "${SERVICE_FILE}" ]; then
  24. if [ "$(cat "${SERVICE_FILE}")" == "enable" ]; then
  25. lprint "ZUI will be enabled. Disable ${SNAP_NAME}."
  26. else
  27. lprint "ZUI won't be enabled. Keep ${SNAP_NAME} enabled."
  28. fi
  29. else
  30. lprint "The service file for ZUI (${SERVICE_FILE}) is missing. Keep ${SNAP_NAME} enabled."
  31. fi
  32. exit 1
  33. else
  34. lprint "Plug/slot = zui-store is connected, but «${ZUI_STORE}» is missing... WHY! 🤷"
  35. fi
  36. else
  37. lprint "ZUI-store is NOT connected, but why did we end up here then??"
  38. fi
  39. #lprint "Connected ZUI (from: z2m)"