daemonize 570 B

12345678910111213141516171819202122
  1. #!/usr/bin/env bash
  2. if ! snapctl is-connected raw-usb; then
  3. echo "Failed to enable ${SNAP_NAME} service!"
  4. echo ""
  5. echo "Consult the help command:"
  6. echo "${SNAP_NAME}.exec --help"
  7. echo ""
  8. echo "Ensure ${SNAP_NAME} is booting successfully before daemonize it"
  9. echo "by running the app manually (remove the --help flag)."
  10. exit 1
  11. fi
  12. snapctl start "${SNAP_NAME}.${SNAP_NAME}" --enable
  13. if [ $? -eq 0 ]; then
  14. echo "Service enabled! Follow logs with"
  15. echo "$ snap logs ${SNAP_NAME}"
  16. exit 0
  17. fi
  18. echo "Failed enabling service"
  19. exit 1