connect-plug-zui-store 1.4 KB

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