minidlna.init.d.script 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #! /bin/sh
  2. # chkconfig: 345 98 16
  3. # description: Fedora Startup/shutdown script for MiniDLNA daemon
  4. # If you have chkconfig, simply:
  5. # chkconfig --add minildna
  6. # Proper init scripts on Linux systems normally require setting lock
  7. # and pid files under /var/run as well as reacting to network
  8. # settings, so you should treat this with care.
  9. # Original author: Perry Clark <omfgppc (at) gmail.com>
  10. # modified by IWAI, Masaharu <iwaim.sub@gmail.com>
  11. # Source function library.
  12. . /etc/rc.d/init.d/functions
  13. if [ -f /etc/sysconfig/minidlna ]; then
  14. . /etc/sysconfig/minidlna
  15. fi
  16. RETVAL=0
  17. LOCK_FILE=/var/lock/subsys/minidlna
  18. # Installation details
  19. MINIDLNA="/usr/sbin/minidlnad"
  20. CONF="/etc/minidlna/minidlna.conf"
  21. # Where to keep a log file
  22. MINIDLNA_LOG="/var/log/minidlna/minidlna.log"
  23. # Where the PID lives
  24. PID_FILE="/var/run/minidlnad.pid"
  25. # The path that is to be used for the script
  26. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  27. set -e
  28. # Only start if we can find the minidlna.conf.
  29. test -x $MINIDLNA || exit 0
  30. start() {
  31. echo -n "Starting MiniDLNA: "
  32. $MINIDLNA -f $CONF -P $PID_FILE >> $MINIDLNA_LOG 2>&1
  33. RETVAL=$?
  34. [ $RETVAL -eq 0 ] && success || failure
  35. echo
  36. [ $RETVAL -eq 0 ] && touch $LOCK_FILE
  37. return $RETVAL
  38. }
  39. stop() {
  40. pid=0
  41. if [ -f $PID_FILE ]; then
  42. pid=`cat $PID_FILE`
  43. echo -n "Stopping MiniDLNA: "
  44. kill $pid
  45. RETVAL=$?
  46. [ $RETVAL -eq 0 ] && success || failure
  47. echo
  48. [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
  49. return $RETVAL
  50. fi
  51. }
  52. # Parse command line parameters.
  53. case $1 in
  54. start)
  55. start
  56. ;;
  57. stop)
  58. stop
  59. ;;
  60. restart|reload|force-reload)
  61. echo "Restarting MiniDLNA: "
  62. stop
  63. sleep 2
  64. start
  65. ;;
  66. *)
  67. # Print help
  68. echo "Usage: /etc/init.d/minidlna {start|stop|restart|reload|force-reload}"
  69. exit 1
  70. ;;
  71. esac
  72. exit $?