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 | # modified by IWAI, Masaharu <iwaim.sub@gmail.com> |
---|
15 | |
---|
16 | # Source function library. |
---|
17 | . /etc/rc.d/init.d/functions |
---|
18 | |
---|
19 | if [ -f /etc/sysconfig/minidlna ]; then |
---|
20 | . /etc/sysconfig/minidlna |
---|
21 | fi |
---|
22 | |
---|
23 | RETVAL=0 |
---|
24 | LOCK_FILE=/var/lock/subsys/minidlna |
---|
25 | |
---|
26 | # Installation details |
---|
27 | MINIDLNA="/usr/sbin/minidlnad" |
---|
28 | CONF="/etc/minidlna/minidlna.conf" |
---|
29 | |
---|
30 | # Where to keep a log file |
---|
31 | MINIDLNA_LOG="/var/log/minidlna/minidlna.log" |
---|
32 | |
---|
33 | # Where the PID lives |
---|
34 | PID_FILE="/var/run/minidlnad.pid" |
---|
35 | |
---|
36 | # The path that is to be used for the script |
---|
37 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
---|
38 | |
---|
39 | set -e |
---|
40 | |
---|
41 | # Only start if we can find the minidlna.conf. |
---|
42 | test -x $MINIDLNA || exit 0 |
---|
43 | |
---|
44 | start() { |
---|
45 | echo -n "Starting MiniDLNA: " |
---|
46 | $MINIDLNA -f $CONF -P $PID_FILE >> $MINIDLNA_LOG 2>&1 |
---|
47 | RETVAL=$? |
---|
48 | [ $RETVAL -eq 0 ] && success || failure |
---|
49 | echo |
---|
50 | [ $RETVAL -eq 0 ] && touch $LOCK_FILE |
---|
51 | return $RETVAL |
---|
52 | } |
---|
53 | |
---|
54 | stop() { |
---|
55 | pid=0 |
---|
56 | if [ -f $PID_FILE ]; then |
---|
57 | pid=`cat $PID_FILE` |
---|
58 | echo -n "Stopping MiniDLNA: " |
---|
59 | kill $pid |
---|
60 | RETVAL=$? |
---|
61 | [ $RETVAL -eq 0 ] && success || failure |
---|
62 | echo |
---|
63 | [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE |
---|
64 | return $RETVAL |
---|
65 | fi |
---|
66 | } |
---|
67 | |
---|
68 | # Parse command line parameters. |
---|
69 | case $1 in |
---|
70 | start) |
---|
71 | start |
---|
72 | ;; |
---|
73 | stop) |
---|
74 | stop |
---|
75 | ;; |
---|
76 | |
---|
77 | restart|reload|force-reload) |
---|
78 | echo "Restarting MiniDLNA: " |
---|
79 | |
---|
80 | stop |
---|
81 | sleep 2 |
---|
82 | start |
---|
83 | |
---|
84 | ;; |
---|
85 | |
---|
86 | *) |
---|
87 | # Print help |
---|
88 | echo "Usage: /etc/init.d/minidlna {start|stop|restart|reload|force-reload}" |
---|
89 | exit 1 |
---|
90 | ;; |
---|
91 | esac |
---|
92 | |
---|
93 | exit $? |
---|