forked from geuma/pDLNA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrc.pDLNA
More file actions
executable file
·109 lines (100 loc) · 2.08 KB
/
rc.pDLNA
File metadata and controls
executable file
·109 lines (100 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
#
# pDLNA - a perl DLNA media server
# Copyright (C) 2010-2011 Stefan Heumader <stefan@heumader.at>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
BIN="./pDLNA.pl"
PRG="pDLNA"
CFGFILE="/etc/pdlna.conf"
if [ "x$CFGFILE" = "x" ]; then
CFGFILE="/etc/pdlna.conf"
fi
PIDFILE=`grep ^PIDFile $CFGFILE | awk {'print $2'}`
if [ "x$PIDFILE" = "x" ]; then
PIDFILE="/var/run/pdlna.pid"
fi
start() {
PRG_PID=""
if [ -f $PIDFILE ]; then
PRG_PID=`cat $PIDFILE`
if [ "x$PRG_PID" = "x" ]; then
echo "Starting $PRG ..."
$BIN -f $CFGFILE
else
if [ -d "/proc/$PRG_PID" ]; then
echo "$PRG is already running with PID $PRG_PID";
else
echo "Starting $PRG ..."
$BIN -f $CFGFILE
fi
fi
else
echo "Starting $PRG ..."
$BIN -f $CFGFILE
fi
}
stop() {
PRG_PID=""
if [ -e $PIDFILE ]; then
PRG_PID=`cat $PIDFILE`
fi
if [ "x$PRG_PID" = "x" ]; then
echo "$PRG is NOT running."
else
if [ -d "/proc/$PRG_PID" ]; then
echo "Stopping $PRG ..."
/bin/rm -f $PIDFILE
kill $PRG_PID
else
/bin/rm -f $PIDFILE
fi
fi
}
status () {
PRG_PID=""
if [ -e $PIDFILE ]; then
PRG_PID=`cat $PIDFILE`
fi
if [ "x$PRG_PID" = "x" ]; then
echo "$PRG is NOT running."
else
if [ -d "/proc/$PRG_PID" ]; then
echo "$PRG is running with PID $PRG_PID";
else
/bin/rm -f $PIDFILE
echo "$PRG is NOT running."
fi
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
status)
status
;;
*)
echo "usage: $0 {start|stop|restart|status}"
exit
esac