updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / tircd / rc-tircd
blob863456ac0ba59ca0b7dc838d302f0fe4a1e372bb
1 #!/bin/bash
3 daemon_name=tircd
5 . /etc/rc.conf
6 . /etc/rc.d/functions
8 if [ -x /etc/conf.d/$daemon_name.conf ]; then
9 . /etc/conf.d/$daemon_name.conf
12 get_pid() {
13 pidof -o %PPID -x $daemon_name.pl
16 case "$1" in
17 start)
18 stat_busy "Starting $daemon_name daemon"
20 PID=$(get_pid)
21 if [ -z "$PID" ]; then
22 [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
23 # RUN
24 su tircd -c "$daemon_name.pl $CFGFILE &"
26 if [ $? -gt 0 ]; then
27 stat_fail
28 exit 1
29 else
30 echo $(get_pid) > /var/run/$daemon_name.pid
31 add_daemon $daemon_name
32 stat_done
34 else
35 stat_fail
36 exit 1
40 stop)
41 stat_busy "Stopping $daemon_name daemon"
42 PID=$(get_pid)
43 # KILL
44 [ ! -z "$PID" ] && kill $PID &> /dev/null
46 if [ $? -gt 0 ]; then
47 stat_fail
48 exit 1
49 else
50 rm -f /var/run/$daemon_name.pid &> /dev/null
51 rm_daemon $daemon_name
52 stat_done
56 restart)
57 $0 stop
58 sleep 3
59 $0 start
62 status)
63 stat_busy "Checking $daemon_name status";
64 ck_status $daemon_name
68 echo "usage: $0 {start|stop|restart|status}"
69 esac
71 exit 0