forked from DDVTECH/mistserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmistserver.init
72 lines (65 loc) · 1.53 KB
/
mistserver.init
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
#! /bin/sh
### BEGIN INIT INFO
# Provides: mistserver
# Required-Start: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: MistServer service
# Description: MistServer - next generation multimedia server
### END INIT INFO
NAME=MistController
DESC="MistServer"
CFG_FILE=/etc/mistserver.conf
LOG_FILE=/var/log/mistserver.log
PID_FILE=/var/run/mistserver.pid
# Source function library.
. /etc/rc.d/init.d/functions
#
# Function that starts the daemon/service
#
do_start()
{
echo -n "Starting $DESC" "$NAME"
MistController -d -L $LOG_FILE -c $CFG_FILE
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/$NAME && echo $!>$PID_FILE && echo_success || echo_failure
echo
return $RETVAL
}
#
# Function that stops the daemon/service
#
do_stop()
{
echo -n "Stopping $DESC" "$NAME"
killall MistController >/dev/null 2>&1
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/$NAME $PID_FILE && echo_success || echo_failure
echo
return $RETVAL
}
do_restart()
{
echo -n "Restarting $DESC" "$NAME"
[[ -f /var/lock/subsys/$NAME ]] && killall MistController >/dev/null 2>&1 && rm -f /var/lock/subsys/$NAME $PID_FILE && sleep 2
MistController -d -L $LOG_FILE -c $CFG_FILE
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/$NAME && echo $!>$PID_FILE && echo_success || echo_failure
echo
return $RETVAL
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart)
do_restart
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
exit 3
;;
esac