summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-12-05 20:05:43 +0000
committerRoy Marples <roy@marples.name>2009-12-05 20:05:43 +0000
commit22e2a4f0a156c566f0c460c2229a19dbff4e0553 (patch)
treeb84fa2396e6b422028c76ee807e76e07544e443e
parentca752a5a2dcd097410e8d5e8df05545751b2c989 (diff)
downloadopenrc-22e2a4f0a156c566f0c460c2229a19dbff4e0553.tar.gz
openrc-22e2a4f0a156c566f0c460c2229a19dbff4e0553.tar.bz2
openrc-22e2a4f0a156c566f0c460c2229a19dbff4e0553.tar.xz
Add support for iproute2 in staticroute.
Fixes #208.
-rw-r--r--conf.d/staticroute.Linux3
-rw-r--r--init.d/staticroute.in53
2 files changed, 41 insertions, 15 deletions
diff --git a/conf.d/staticroute.Linux b/conf.d/staticroute.Linux
index b56bd7c..15956cd 100644
--- a/conf.d/staticroute.Linux
+++ b/conf.d/staticroute.Linux
@@ -1,2 +1,5 @@
# Example static route. See route(8) for syntax.
#staticroute="net 192.168.0.0 netmask 255.255.0.0 gw 10.73.1.1"
+
+# Example static route using iproute2. See ip(8) for syntax.
+#staticiproute="192.168.0.0/24 via 10.73.1.1"
diff --git a/init.d/staticroute.in b/init.d/staticroute.in
index 0b49ca9..8aea55c 100644
--- a/init.d/staticroute.in
+++ b/init.d/staticroute.in
@@ -15,24 +15,36 @@ depend()
keyword -jail -prefix -vserver
}
+pre_flight_checks()
+{
+ route=route
+ [ -s /etc/route.conf ] && return 0
+
+ if [ -n "$staticiproute" ]; then
+ route="ip route"
+ staticroute="$staticiproute"
+ fi
+}
+
dump_args()
{
if [ -s /etc/route.conf ]; then
cat /etc/route.conf
- else
- case "$staticroute" in
- *"$__nl"*)
- echo "$staticroute"
- ;;
- *)
- (
- set -o noglob
- IFS=';'; set -- $staticroute
- IFS="$__nl"; echo "$*"
- )
- ;;
- esac
+ return $?
fi
+
+ case "$staticroute" in
+ *"$__nl"*)
+ echo "$staticroute"
+ ;;
+ *)
+ (
+ set -o noglob
+ IFS=';'; set -- $staticroute
+ IFS="$__nl"; echo "$*"
+ )
+ ;;
+ esac
}
do_routes()
@@ -41,6 +53,8 @@ do_routes()
[ "$RC_UNAME" != Linux ] && xtra=-q
ebegin "$1 static routes"
+ eindent
+ pre_flight_checks
dump_args | while read args; do
[ -z "$args" ] && continue
case "$args" in
@@ -53,10 +67,19 @@ do_routes()
[ $2 = "del" -o $2 = "delete" ] && eval ${args#*-}
;;
*)
- route $xtra $2 -$args
- ;;
+ veinfo "$args"
+ case "$route" in
+ "ip route")
+ ip route $2 $args
+ ;;
+ *)
+ route $xtra $2 -$args
+ ;;
+ esac
+ veend $?
esac
done
+ eoutdent
eend 0
}