Advertisement
Powderking

squeezeboxserver

Jun 26th, 2011
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. $ cat /etc/init.d/squeezeboxserver
  2. #!/bin/sh
  3. #
  4. # $Id$
  5. #
  6. # squeezeboxserver initscript for squeezebox.pl
  7. # This file should be placed in /etc/init.d.
  8. #
  9. # Original Author: Mattias Holmlund
  10. #
  11. # Updated By: Dan Sully
  12.  
  13. #
  14. ### BEGIN INIT INFO
  15. # Provides: squeezeboxserver
  16. # Required-Start: $all
  17. # Required-Stop: $all
  18. # Should-Start: $all
  19. # Should-Stop: $all
  20. # Default-Start: 2 3 4 5
  21. # Default-Stop: 0 1 6
  22. # Short-Description: Startup script for the SqueezeBox Music Server
  23. # Description: SqueezeBox Server powers the Squeezebox, Transporter and SLIMP3 network music \
  24. # players and is the best software to stream your music to any software MP3 \
  25. # player. It supports MP3, AAC, WMA, FLAC, Ogg Vorbis, WAV and more!
  26. ### END INIT INFO
  27. #
  28.  
  29. set -e
  30.  
  31. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  32. DESC="Squeezebox Server"
  33. NAME=squeezeboxserver
  34. DAEMON=/usr/sbin/$NAME
  35. DAEMON_SAFE=/usr/sbin/${NAME}_safe
  36. PIDFILE=/var/run/$NAME.pid
  37. SCRIPTNAME=/etc/init.d/$NAME
  38. SLIMUSER=$NAME
  39. PREFSDIR=/var/lib/$NAME/prefs
  40. LOGDIR=/var/log/$NAME/
  41. CACHEDIR=/var/lib/$NAME/cache
  42. CHARSET=utf8
  43. SLIMOPTIONS=
  44.  
  45. # Read config file if it is present.
  46. if [ -r /etc/default/$NAME ]
  47. then
  48. . /etc/default/$NAME
  49. fi
  50.  
  51. #
  52. # Function that starts the daemon/service.
  53. #
  54. d_start() {
  55. # Use squeezeboxserver_safe to restart the daemon when
  56. # it dies. This must be done to handle mysql restarts.
  57. start-stop-daemon --start --quiet \
  58. --chuid $SLIMUSER \
  59. --pidfile $PIDFILE \
  60. --exec $DAEMON_SAFE \
  61. --background \
  62. --make-pidfile \
  63. -- \
  64. $DAEMON \
  65. --prefsdir $PREFSDIR \
  66. --logdir $LOGDIR \
  67. --cachedir $CACHEDIR \
  68. --charset=$CHARSET \
  69. $SLIMOPTIONS
  70. }
  71.  
  72. d_start_direct() {
  73. start-stop-daemon --start --quiet \
  74. --chuid $SLIMUSER \
  75. --pidfile $PIDFILE \
  76. --exec $DAEMON \
  77. -- \
  78. --pidfile $PIDFILE \
  79. --daemon \
  80. --prefsdir $PREFSDIR \
  81. --logdir $LOGDIR \
  82. --cachedir $CACHEDIR \
  83. --charset=$CHARSET \
  84. $SLIMOPTIONS
  85. }
  86.  
  87. # Function that stops the daemon/service.
  88. #
  89. d_stop() {
  90.  
  91. ## This is a bug in the start-stop-daemon that checks the PID name from the /proc/PID/stat filesystem...
  92. ## Unfortunately this cuts-off the name of the daemon because its longer now, and then it doesnt get
  93. ## caught by the start-stop-daemon. The daemon actually reports it as squeezeboxserve instead of
  94. ## squeezeboxserver_safe.
  95. start-stop-daemon --oknodo --stop --pidfile $PIDFILE --retry=TERM/30/KILL/5
  96. }
  97.  
  98. #
  99. # Function that sends a SIGHUP to the daemon/service.
  100. #
  101. d_reload() {
  102. start-stop-daemon --stop --quiet --pidfile $PIDFILE --signal 1
  103. }
  104.  
  105. case "$1" in
  106. start)
  107. echo -n "Making sure that $DESC is not running first: "
  108. d_stop
  109. echo -n "Starting $DESC"
  110. d_start
  111. echo "."
  112. ;;
  113. stop)
  114. echo -n "Stopping $DESC"
  115. d_stop
  116. echo "."
  117. ;;
  118. restart|force-reload)
  119. #
  120. # If the "reload" option is implemented, move the "force-reload"
  121. # option to the "reload" entry above. If not, "force-reload" is
  122. # just the same as "restart".
  123. #
  124. echo -n "Restarting $NAME"
  125. d_stop
  126. d_start
  127. echo "."
  128. ;;
  129. *)
  130. # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  131. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  132. exit 1
  133. ;;
  134. esac
  135.  
  136. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement