updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / polipo-git / polipo.rc.d
blobf9bbd478359fa9ec49afaff75ae96862ef890a08
1 #!/bin/bash
2 . /etc/rc.conf
3 . /etc/rc.d/functions
5 DAEMON=polipo
6 ARGS="daemonise=true pidFile=/var/run/$DAEMON/$DAEMON.pid"
7 PID=$(pidof -o %PPID /usr/bin/$DAEMON)
9 case $1 in
10 start)
11 stat_busy "Starting $DAEMON"
12 if ck_daemon $DAEMON; then
13 [[ ! -d /var/run/$DAEMON ]] && install -d $DAEMON /var/run/$DAEMON
14 /usr/bin/$DAEMON $ARGS >/dev/null 2>&1
15 if [[ $? != 0 ]]; then
16 stat_fail
17 else
18 add_daemon polipo
19 stat_done
21 else
22 stat_fail
25 stop)
26 stat_busy "Stopping $DAEMON"
27 if ! ck_daemon $DAEMON; then
28 kill $PID >/dev/null 2>&1
29 if [[ $? != 0 ]]; then
30 stat_fail
31 else
32 rm_daemon $DAEMON
33 stat_done
35 else
36 stat_fail
39 purge)
40 stat_busy "Purging $DAEMON"
41 [[ ! -d /var/run/$DAEMON ]] && install -d $DAEMON /var/run/$DAEMON
42 if ! ck_daemon $DAEMON; then
43 kill -USR1 $PID >/dev/null 2>&1
44 sleep 1
45 /usr/bin/$DAEMON -x $ARGS >/dev/null 2>&1 || stat_fail
46 kill -USR2 $PID >/dev/null 2>&1
47 stat_done
48 else
49 /usr/bin/$DAEMON -x $ARGS >/dev/null 2>&1 || stat_fail
50 stat_done
53 restart)
54 $0 stop
55 $0 start
58 echo "usage: $0 {start|stop|restart|purge}"
60 esac