source: projects/specs/trunk/nonfree/self-build-minidlna/minidlna.init.d.script @ 11755

Revision 11755, 1.8 KB checked in by iwaim, 6 years ago (diff)

self-build-minidlna 1.2.1-3

Line 
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
19if [ -f /etc/sysconfig/minidlna ]; then
20        . /etc/sysconfig/minidlna
21fi
22
23RETVAL=0
24LOCK_FILE=/var/lock/subsys/minidlna
25
26# Installation details
27MINIDLNA="/usr/sbin/minidlnad"
28CONF="/etc/minidlna/minidlna.conf"
29
30# Where to keep a log file
31MINIDLNA_LOG="/var/log/minidlna/minidlna.log"
32
33# Where the PID lives
34PID_FILE="/var/run/minidlnad.pid"
35
36# The path that is to be used for the script
37PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
38
39set -e
40
41# Only start if we can find the minidlna.conf.
42test -x $MINIDLNA || exit 0
43
44start() {
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
54stop() {
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.
69case $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        ;;
91esac
92
93exit $?
Note: See TracBrowser for help on using the repository browser.