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