1 |
#!/bin/sh |
2 |
# irkerd Init script for running the irkerd daemon |
3 |
# |
4 |
# chkconfig: - 98 02 |
5 |
# |
6 |
# description: Starts the irkerd daemon |
7 |
# processname: irkerd |
8 |
|
9 |
### BEGIN INIT INFO |
10 |
# Provides: irkerd |
11 |
# Required-Start: $local_fs $network $syslog |
12 |
# Required-Stop: $network |
13 |
# Default-Start: 2 3 4 5 |
14 |
# Default-Stop: 0 1 6 |
15 |
# Short-Description: Starts the irkerd daemon |
16 |
# Description: irkerd is an IRC Message Relay |
17 |
### END INIT INFO |
18 |
|
19 |
# Local variables |
20 |
DAEMON_NAME=irkerd |
21 |
DAEMON_PROCESS=$DAEMON_NAME |
22 |
DAEMON_BINARY=/usr/bin/$DAEMON_PROCESS |
23 |
DAEMON_USER=irker |
24 |
LOCKFILE=/var/lock/subsys/$DAEMON_PROCESS |
25 |
PIDFILE=/var/run/$DAEMON_PROCESS.pid |
26 |
|
27 |
RETVAL=0 |
28 |
|
29 |
# Source function library. |
30 |
. /etc/rc.d/init.d/functions |
31 |
|
32 |
# load service configuration |
33 |
[ -f /etc/sysconfig/$DAEMON_NAME ] && . /etc/sysconfig/$DAEMON_NAME |
34 |
|
35 |
start() { |
36 |
if [ ! -f $LOCKFILE ]; then |
37 |
gprintf "Starting %s daemon: " "$DAEMON_NAME" |
38 |
su - $DAEMON_USER -s /bin/sh --session-command="exec $DAEMON_BINARY" & |
39 |
RETVAL=$? |
40 |
echo $! > $PIDFILE |
41 |
[ $RETVAL -eq 0 ] && echo_success && touch $LOCKFILE |
42 |
echo |
43 |
fi |
44 |
return $RETVAL |
45 |
} |
46 |
|
47 |
stop() { |
48 |
gprintf "Stopping %s daemon: " "$DAEMON_NAME" |
49 |
killproc $DAEMON_PROCESS |
50 |
RETVAL=$? |
51 |
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE |
52 |
echo |
53 |
return $RETVAL |
54 |
} |
55 |
|
56 |
restart() { |
57 |
stop |
58 |
start |
59 |
} |
60 |
|
61 |
reload() { |
62 |
stop |
63 |
start |
64 |
} |
65 |
|
66 |
|
67 |
|
68 |
case "$1" in |
69 |
start) |
70 |
start |
71 |
;; |
72 |
stop) |
73 |
stop |
74 |
;; |
75 |
restart) |
76 |
restart |
77 |
;; |
78 |
condrestart|condreload) |
79 |
if [ -f $LOCKFILE ]; then |
80 |
restart |
81 |
fi |
82 |
;; |
83 |
status) |
84 |
status $DAEMON_PROCESS |
85 |
RETVAL=$? |
86 |
;; |
87 |
reload) |
88 |
reload |
89 |
;; |
90 |
*) |
91 |
gprintf "Usage: %s {start|stop|restart|reload|condrestart|condreload|status}\n" "$0" |
92 |
RETVAL=1 |
93 |
;; |
94 |
esac |
95 |
|
96 |
exit $RETVAL |