1. #!/bin/bash
  2. CARTON=/usr/local/bin/carton
  3. [ -x "${CARTON}" ] || exit 1
  4. LOG=/var/log/musicbrainz
  5. PIDFILE=/var/run/musicbrainz/server.pid
  6. cd $HOME/musicbrainz-server
  7. case "$1" in
  8. start)
  9. if [ -f "${PIDFILE}" ]; then
  10. echo "${PIDFILE}" exists. Is the server already running?
  11. exit 1
  12. fi
  13. $CARTON exec -- plackup -Ilib -r >> $LOG/server.log 2>&1 &
  14. PID=$!
  15. echo $PID > "${PIDFILE}"
  16. echo "Server started with PID=$PID"
  17. ;;
  18. stop)
  19. if [ -f "${PIDFILE}" ]; then
  20. PID=$(cat "${PIDFILE}")
  21. kill $PID
  22. rm "${PIDFILE}"
  23. echo "Server stopped."
  24. else
  25. echo "Can't find ${PIDFILE}. Is the server running?"
  26. fi
  27. ;;
  28. hourly)
  29. $CARTON exec -- ./admin/replication/LoadReplicationChanges >> $LOG/hourly.log 2>&1
  30. ;;
  31. daily)
  32. #$CARTON exec -- ./admin/cron/daily.sh >> $LOG/daily.log 2>&1
  33. ;;
  34. weekly)
  35. #$CARTON exec -- ./admin/cron/weekly.sh >> $LOG/weekly.log 2>&1
  36. ;;
  37. *)
  38. echo $"Usage: $0 {start|stop|hourly|daily|weekly}"
  39. exit 1
  40. esac
  41. exit 0