updated on Thu Jan 12 08:01:00 UTC 2012
[aur-mirror.git] / ptrtd / rc-ptrtd
blob08385c4ef96e8c43eaad9e97971a84467a277e56
1 #!/bin/bash
3 daemon_name=ptrtd
5 . /etc/rc.d/functions
7 . /etc/conf.d/$daemon_name
9 . /etc/rc.conf
11 get_pid() {
12 pidof $daemon_name
15 case "$1" in
16 start)
17 stat_busy "Starting $daemon_name daemon"
19 PID=`get_pid`
20 if [ -z "$PID" ]; then
21 [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
22 # RUN
24 lsmod | grep tun 2>&1 > /dev/null
25 if [ $? != "0" ]; then
26 modprobe tun
29 /usr/sbin/$daemon_name $PTRTD_ARGS 2>&1 > /dev/null
31 if [ $? -gt 0 ]; then
32 stat_fail
33 exit 1
34 else
35 echo `get_pid` > /var/run/$daemon_name.pid
36 add_daemon $daemon_name
37 stat_done
39 else
40 stat_fail
41 exit 1
45 stop)
46 stat_busy "Stopping $daemon_name daemon"
47 PID=`get_pid`
48 # KILL
49 [ ! -z "$PID" ] && kill $PID &> /dev/null
51 if [ $? -gt 0 ]; then
52 stat_fail
53 exit 1
54 else
55 rm -f /var/run/$daemon_name.pid &> /dev/null
56 rm_daemon $daemon_name
57 stat_done
61 restart)
62 $0 stop
63 sleep 3
64 $0 start
67 echo "usage: $0 {start|stop|restart}"
68 esac
69 exit 0