Advertisement
Guest User

minidlna.conf

a guest
Mar 8th, 2012
1,501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.12 KB | None | 0 0
  1. #! /bin/sh
  2.  
  3. # chkconfig: 345 99 10
  4. # description: Fedora Startup/shutdown script for MiniDLNA daemon
  5.  
  6. # If you have chkconfig, simply:
  7. # chkconfig --add minildna
  8.  
  9. # Proper init scripts on Linux systems normally require setting lock
  10. # and pid files under /var/run as well as reacting to network
  11. # settings, so you should treat this with care.
  12.  
  13. # Original author:  Perry Clark <omfgppc (at) gmail.com>
  14. # Edited by: David Gleich <wister.geo (at) yahoo.com>
  15.  
  16. ## EDIT FROM HERE
  17.  
  18. # Source function library.
  19. . /etc/rc.d/init.d/functions
  20. # Source networking configuration.
  21. . /etc/sysconfig/network
  22.  
  23.  
  24. # Installation details
  25. MINIDLNA="/usr/sbin/minidlna"
  26. ARGS="/etc/minidlna.conf"
  27.  
  28. # Where to keep a log file
  29. MINIDLNA_LOG="/var/log/minidlna.log"
  30.  
  31. # Where the PID & Lockfile lives
  32. PID_FILE="/var/run/minidlna.pid"
  33. LOCKFILE="/var/lock/subsys/minidlna"
  34. RETVAL=0
  35.  
  36. ## STOP EDITING HERE
  37.  
  38. # The path that is to be used for the script
  39. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  40.  
  41. set -e
  42.  
  43. # Only start if we can find the minidlna.conf.
  44. test -x $MINIDLNA || exit 0
  45.  
  46.  
  47. # Parse command line parameters.
  48. case $1 in
  49.   start)
  50.         echo -n "Starting MiniDLNA: "
  51.         $MINIDLNA -f $ARGS -P $PID_FILE  >> $MINIDLNA_LOG 2>&1
  52.         RETVAL=$?
  53.         [ $RETVAL -eq 0 ] && touch $LOCKFILE
  54.         echo_success
  55.         echo
  56.         ;;
  57.   stop)
  58.         echo -n "Stopping MiniDLNA: "
  59.         RETVAL=$?
  60.            for pidf in `/bin/ls $PID_FILE 2>/dev/null`; do
  61.             if [ -s $pidf ]; then
  62.                 kill `cat $pidf` >/dev/null 2>&1
  63.                 RETVAL=$?
  64.                 [ $RETVAL -eq 0 ] && echo_success
  65.                 [ $RETVAL -ne 0 ] && echo_failure
  66.             fi
  67.                         rm -rf $PIF_FILE
  68.            [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
  69.            done
  70.         echo
  71.         ;;
  72.   restart|reload|force-reload)
  73.         echo "Restarting MiniDLNA: "
  74.  
  75.     $0 stop
  76.         sleep 2
  77.         $0 start
  78.  
  79.         ;;
  80.   *)
  81.         # Print help
  82.         echo "Usage: /etc/init.d/minidlna {start|stop|restart|reload|force-reload}"
  83.         exit 1
  84.         ;;
  85. esac
  86.  
  87. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement