-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-gofish
executable file
·48 lines (42 loc) · 1.1 KB
/
init-gofish
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
#!/bin/bash
# The following two lines enable chkconfig(1) to manipulate this script
# chkconfig: 2345 99 01
# description: control of GoFish http daemon
# modified from Jef Poskanzer's tiny/turbo/throttling http daemon
# source function library
. /etc/rc.d/init.d/functions
pidfile=/var/run/gofish.pid
pid=`cat $pidfile 2>/dev/null`
if test -n "$pid" && kill -0 $pid 2>/dev/null; then
dead=no
else
dead=yes
fi
die(){
echo -n "$*"; echo_failure; echo ''
exit 1;
}
case "$1" in
start) test "$dead" = yes || die gofish is already running
echo -n "Starting gofish: "
daemon /usr/sbin/gofish -d -c /etc/gofish-www.conf
touch /var/lock/subsys/gofish
echo_success;echo ''
exit 0
;;
stop) echo -n "Stopping gofish: "
signal=HUP
;;
kill) echo -n "Violently killing gofish: "
signal=KILL
;;
status) status gofish; exit $?;;
restart) $0 stop; sleep 2; exec $0 start;;
*) die "Usage: gofish {start|stop|restart|status}";;
esac
test "$dead" = no || die gofish is not running
kill -$signal $pid
sleep 2
kill -0 $pid 2>/dev/null && die "gofish[$pid] will not die"
rm -f /var/lock/subsys/gofish
echo_success; echo ''