configure 861 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env bash
  2. set -e
  3. # silence is golden.
  4. CONF_DIR=$(snapctl get ozw.config-dir)
  5. USER_DIR=$(snapctl get ozw.user-dir)
  6. if [ ! -d "${CONF_DIR}" -a ! -w "${CONF_DIR}" ]; then
  7. echo "Insufficient priviliges for ${CONF_DIR}."
  8. echo "Check that the directory exists and that it's writable."
  9. echo "Directory should be a sub-dir of either"
  10. echo "- ${SNAP_DATA}"
  11. echo "- ${SNAP_USER_DATA}"
  12. exit 1
  13. fi
  14. if [ ! -d "${USER_DIR}" -a ! -w "${USER_DIR}" ]; then
  15. echo "Insufficient priviliges for ${USER_DIR}."
  16. echo "Check that the directory exists and that it's writable."
  17. echo "Directory should be a sub-dir of either"
  18. echo "- ${SNAP_DATA}"
  19. echo "- ${SNAP_USER_DATA}"
  20. exit 1
  21. fi
  22. RUNNING=$(snapctl services | grep "${SNAP_NAME}" | grep inactive | wc -l)
  23. if [ ${RUNNING} -eq 0 ]; then
  24. snapctl restart "${SNAP_NAME}"
  25. fi