aboutsummaryrefslogtreecommitdiffstats
path: root/main/pingu/pingu.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-08-21 14:55:52 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-08-21 14:56:56 +0000
commitcf10e9169fa34e9e09f055f4fe338045d34bd372 (patch)
tree3536fe83bcddd6b1b911f612e8155ab6fdc02563 /main/pingu/pingu.initd
parentba29d2187341d958c329d19b4a78310a084172b8 (diff)
downloadaports-cf10e9169fa34e9e09f055f4fe338045d34bd372.tar.bz2
aports-cf10e9169fa34e9e09f055f4fe338045d34bd372.tar.xz
main/pingu: add support for static route rules
Users can add static route rules in /etc/pingu/route-rules The rules will be added when startup and removed when stop
Diffstat (limited to 'main/pingu/pingu.initd')
-rw-r--r--main/pingu/pingu.initd25
1 files changed, 25 insertions, 0 deletions
diff --git a/main/pingu/pingu.initd b/main/pingu/pingu.initd
index a7a6bef369..47353e79f1 100644
--- a/main/pingu/pingu.initd
+++ b/main/pingu/pingu.initd
@@ -4,8 +4,33 @@ description="MultiISP load balancing and failover"
command=/usr/sbin/pingu
command_args="-d"
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
+}