blob: 9e64a20fdd811583d258f1cfdb2420bbb25532ae [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001#!/bin/sh
2
3NAME="minidlna"
4DAEMON=/usr/sbin/minidlnad
5SCRIPTNAME=/etc/init.d/$NAME
6PIDFILE=/var/run/$NAME.pid
7CONF=/etc/$NAME.conf
8ARGS="-f $CONF"
9
10# Exit if the package is not installed
11[ -x "$DAEMON" ] || exit 0
12
13start_function() {
14
15 export PATH=$PWD:$PATH
16
17 if [ -f ${PIDFILE} ]; then
18 echo "$SCRIPTNAME already running with PID #`cat $PIDFILE` ( according to ${PIDFILE} )";
19 exit 0
20 fi
21
22 $DAEMON $ARGS
23
24 pid=$!
25
26 if [ "$pid" != "" ]; then
27 echo -n "$pid" > ${PIDFILE}
28 fi
29}
30
31stop_function() {
32
33 export PATH=$PWD:$PATH
34
35 if [ ! -e "${PIDFILE}" ]; then
36 echo "${SCRIPTNAME} not running ( according to ${PIDFILE} )";
37 exit 1;
38 fi
39 PID=`cat ${PIDFILE}`
40 kill -INT ${PID}
41 rm -f ${PIDFILE}
42}
43
44case $1 in
45 "start")
46 start_function
47 ;;
48 "stop")
49 stop_function
50 ;;
51 *)
52 echo "Usage: $0 {start | stop}"
53
54esac