summaryrefslogtreecommitdiff
path: root/community/polipo/polipo.rc.d
blob: f9bbd478359fa9ec49afaff75ae96862ef890a08 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions

DAEMON=polipo
ARGS="daemonise=true pidFile=/var/run/$DAEMON/$DAEMON.pid"
PID=$(pidof -o %PPID /usr/bin/$DAEMON)

case $1 in
    start)
        stat_busy "Starting $DAEMON"
        if ck_daemon $DAEMON; then
            [[ ! -d /var/run/$DAEMON ]] && install -d $DAEMON /var/run/$DAEMON
            /usr/bin/$DAEMON $ARGS >/dev/null 2>&1
            if [[ $? != 0 ]]; then
                stat_fail
            else
                add_daemon polipo
                stat_done
            fi
        else
            stat_fail
        fi
    ;;
    stop)
        stat_busy "Stopping $DAEMON"
        if ! ck_daemon $DAEMON; then
            kill $PID >/dev/null 2>&1
            if [[ $? != 0 ]]; then
                stat_fail
            else
                rm_daemon $DAEMON
                stat_done
            fi
        else
            stat_fail
        fi
    ;;
    purge)
        stat_busy "Purging $DAEMON"
        [[ ! -d /var/run/$DAEMON ]] && install -d $DAEMON /var/run/$DAEMON
        if ! ck_daemon $DAEMON; then
            kill -USR1 $PID >/dev/null 2>&1
            sleep 1
            /usr/bin/$DAEMON -x $ARGS >/dev/null 2>&1 || stat_fail
            kill -USR2 $PID >/dev/null 2>&1
            stat_done
        else
            /usr/bin/$DAEMON -x $ARGS >/dev/null 2>&1 || stat_fail
            stat_done
        fi
    ;;
    restart)
        $0 stop
        $0 start
    ;;
    *)
        echo "usage: $0 {start|stop|restart|purge}"
    ;;
esac