summaryrefslogtreecommitdiffstats
path: root/main/pingu/pingu.initd
blob: 517bdd892cb6a518c990033b499615f862b16b87 (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
#!/sbin/openrc-run

description="MultiISP load balancing and failover"
command=/usr/sbin/pingu
command_args="-d $pingu_opts"
pidfile=/var/run/pingu/pingu.pid
route_rules=/etc/pingu/route-rules
rundir=${pidfile%/*}

depend() {
	need net
	after firewall
}

start_pre() {
	if ! [ -f "$route_rules" ]; then
		return 0
	fi
	sed -e 's/\#.*//' -e '/^$/d' "$route_rules" | while read line; do
		ebegin "Adding route rule: $line"
		ip rule add $line && echo $line >> $rundir/route-rules
		eend
	done
}

stop_post() {
	if ! [ -f "$rundir"/route-rules ]; then
		return 0
	fi
	while read line; do
		ebegin "Removing route rule: $line"
		ip rule del $line
		eend
	done < "$rundir"/route-rules
	rm "$rundir"/route-rules
}