File: shaperd.init

package info (click to toggle)
shaperd 0.2pre44-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 348 kB
  • ctags: 740
  • sloc: cpp: 3,482; ansic: 685; sh: 105; makefile: 84
file content (81 lines) | stat: -rw-r--r-- 2,044 bytes parent folder | download | duplicates (2)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /bin/sh
# /etc/init.d/shaperd
# (C) 2001. RISKO Gergely (based on skeleton example)

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/shaperd
NAME=shaperd
DESC="TCP/IP Shaper Daemon"

if ( [ ! -f /etc/shaperd/shaperd.conf ] || ( grep "# See the examples dir in /usr/share/doc/shaperd and replace this file" /etc/shaperd/shaperd.conf ) )
then
    echo "You can't use shaperd, until you write the config file for it."
    echo "Please see the examples dir in /usr/share/doc/shaperd, and create"
    echo "the /etc/shaperd/shaperd.conf configuration file!"
    
    exit 0
fi

test -f $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- -c /etc/shaperd/shaperd.conf >/dev/null 2>&1
	echo "$NAME."
	if [ -x /etc/shaperd/up.d ]
	then
	    /etc/shaperd/up.d
	fi
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- -c /etc/shaperd/shaperd.conf >/dev/null 2>&1
	echo "$NAME."
	if [ -x /etc/shaperd/down.d ]
	then
	    /etc/shaperd/down.d
	fi
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --signal 1 --quiet --pidfile \
	    /var/run/$NAME.pid --exec $DAEMON -- -c /etc/shaperd/shaperd.conf >/dev/null 2>&1
	if [ -x /etc/shaperd/down.d ]
	then
	    /etc/shaperd/down.d
	fi
	if [ -x /etc/shaperd/up.d ]
	then
	    /etc/shaperd/up.d
	fi
	;;
  restart)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON -- -c /etc/shaperd/shaperd.conf >/dev/null 2>&1
	sleep 2
	start-stop-daemon --start --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON -- -c /etc/shaperd/shaperd.conf >/dev/null 2>&1
	echo "$NAME."
	if [ -x /etc/shaperd/down.d ]
	then
	    /etc/shaperd/down.d
	fi
	if [ -x /etc/shaperd/up.d ]
	then
	    /etc/shaperd/up.d
	fi
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0