minidlna.init.d.script 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. ## EDIT FROM HERE
  11. # Installation details
  12. MINIDLNA="/usr/sbin/minidlnad"
  13. ARGS="/etc/minidlna/minidlna.conf"
  14. # Where to keep a log file
  15. MINIDLNA_LOG="/var/log/minidlna/minidlna.log"
  16. # Where the PID lives
  17. PID_FILE="/var/run/minidlnad.pid"
  18. ## STOP EDITING HERE
  19. # The path that is to be used for the script
  20. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  21. set -e
  22. # Only start if we can find the minidlna.conf.
  23. test -x $MINIDLNA || exit 0
  24. # Parse command line parameters.
  25. case $1 in
  26. start)
  27. echo -n "Starting MiniDLNA: "
  28. $MINIDLNA -f $ARGS -P $PID_FILE >> $MINIDLNA_LOG 2>&1
  29. echo "ok"
  30. ;;
  31. stop)
  32. echo -n "Stopping MiniDLNA: "
  33. for pidf in `/bin/ls $PID_FILE 2>/dev/null`; do
  34. if [ -s $pidf ]; then
  35. kill `cat $pidf` >/dev/null 2>&1
  36. fi
  37. rm -rf $PIF_FILE
  38. done
  39. echo "ok"
  40. ;;
  41. restart|reload|force-reload)
  42. echo "Restarting MiniDLNA: "
  43. $0 stop
  44. sleep 2
  45. $0 start
  46. ;;
  47. *)
  48. # Print help
  49. echo "Usage: /etc/init.d/minidlna {start|stop|restart|reload|force-reload}"
  50. exit 1
  51. ;;
  52. esac
  53. exit 0