summaryrefslogtreecommitdiff
path: root/package/tinyproxy/files/tinyproxy.init
blob: 3830d95a4d4a51a6607a0225f57620146c2e24d4 (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
#! /bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=tinyproxy
DESC="Tiny HTTP and HTTPS proxy"
case "$1" in
  start)
        if [ -e /var/run/$NAME.pid ]; then
                echo "$DESC: $NAME already started."
                exit 0
        fi
        echo -n "Starting $DESC: $NAME"
        test -e /var/run/$NAME.pid || touch /var/run/$NAME.pid
        /usr/sbin/$NAME
        echo "."
        ;;

  stop)
        if [ ! -e /var/run/$NAME.pid ]; then
                echo "$DESC: $NAME is not running."
                exit 0
        fi
        echo -n "Stopping $DESC: $NAME"
        killall $NAME
        rm -f /var/run/$NAME.pid

        echo "."
        ;;

  restart|force-reload)
        if [ ! -e /var/run/$NAME.pid ]; then
                $0 start
                exit 0
        fi
        echo -n "Restarting $DESC: $NAME"
        killall $NAME
        sleep 1
/usr/sbin/$NAME
        echo "."
        ;;

  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;

esac

exit 0