Advertisement
Guest User

mocp init.d script

a guest
Jan 12th, 2011
439
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.83 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:             MOCP Application Instance
  4. # Required-Start:       $all
  5. # Required-Stop:
  6. # Default-Start:        2 3 4 5
  7. # Default-Stop:         0 1 6
  8. # Short-Description:    starts instance of mocp
  9. # Description:          starts instance of mocp using start-stop-daemon
  10. ### END INIT INFO
  11.  
  12. case "$1" in
  13. start)
  14.         if ! pidof -o %PPID mocp > /dev/null; then
  15.                 export HOME=/home/USER
  16.                 sleep 5
  17.                 start-stop-daemon --start --chuid USER--exec /usr/bin/mocp -- -S
  18.                 /usr/bin/mocp --volume 100 --play
  19.                 sleep 5
  20.                 /usr/bin/mocp --on shuffle
  21.                 /usr/bin/mocp --on autonext
  22.                 /usr/bin/mocp --on repeat
  23.                 echo "Starting MOCP..."
  24.         else
  25.                 echo "MOCP Already Running..."
  26.         fi
  27. ;;
  28.  
  29. stop)
  30.         start-stop-daemon --stop --exec /usr/bin/mocp -- -x
  31. ;;
  32.  
  33. restart)
  34.         start-stop-daemon --stop --exec /usr/bin/mocp -- -x
  35.         sleep 1
  36.         if ! pidof -o %PPID mocp > /dev/null; then
  37.                 export HOME=/home/USER
  38.                 sleep 5
  39.                 start-stop-daemon --start --chuid USER--exec /usr/bin/mocp -- -S
  40.                 /usr/bin/mocp --volume 100 --play
  41.                 sleep 5
  42.                 /usr/bin/mocp --on shuffle
  43.                 /usr/bin/mocp --on autonext
  44.                 /usr/bin/mocp --on repeat
  45.                 echo "Restarting MOCP..."
  46.         else
  47.                 echo "MOCP Already Running, Restart Failed"
  48.         fi
  49.  
  50. ;;
  51.  
  52. status)
  53.         if pidof -o %PPID mocp > /dev/null; then
  54.                 echo "Running"
  55.                 exit 0
  56.         else
  57.                 echo "Not running"
  58.                 exit 1
  59.         fi
  60. ;;
  61.  
  62. *)
  63.         echo "Usage: $0 {start|stop|restart|status}"
  64.         exit 1
Advertisement
Comments
  • fjbernal
    75 days
    # text 0.10 KB | 0 0
    1. You will need to add this two lines at the end of the script
    2. ;;
    3. esac
    4. and of course chmod +x mocp
  • fjbernal
    75 days
    # text 0.29 KB | 0 0
    1. I forgot to mention that the line
    2. start-stop-daemon --start --chuid USER--exec /usr/bin/mocp -- -S
    3. must be
    4. start-stop-daemon --start --chuid USER --exec /usr/bin/mocp -- -S
    5. and you will need to change USER for whatever the name of the user you want to use and to save/play playlists
    6. Regards
Add Comment
Please, Sign In to add comment
Advertisement