diff options
author | Martin Schwenke <martin@meltin.net> | 2012-07-17 20:13:45 +1000 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2012-07-30 11:24:59 +1000 |
commit | 35de9f2583fe17390cfa3d1a1eb8fe755fe4de88 (patch) | |
tree | b915df92a8406975638998b0ad9e77f67598aa73 | |
parent | 3c5374a5c23cb163c2f379f4707997dde317ac56 (diff) | |
download | samba-35de9f2583fe17390cfa3d1a1eb8fe755fe4de88.tar.gz samba-35de9f2583fe17390cfa3d1a1eb8fe755fe4de88.tar.xz samba-35de9f2583fe17390cfa3d1a1eb8fe755fe4de88.zip |
Eventscripts: Clean up 11.routing
The loops can all be done without cat or grep.
The pair of loops in updateip is combined into a single loop.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 96fdda124f5511fb76190e7c7a7f0b98e6b01a31)
-rwxr-xr-x | ctdb/config/events.d/11.routing | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/ctdb/config/events.d/11.routing b/ctdb/config/events.d/11.routing index b6093a2a43..38a0258c60 100755 --- a/ctdb/config/events.d/11.routing +++ b/ctdb/config/events.d/11.routing @@ -21,20 +21,19 @@ loadconfig case "$1" in recovered|ipreallocated) - cat $CTDB_BASE/static-routes | while read IFACE DEST GW; do - ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null - done + while read iface dest gw; do + ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1 + done <"${CTDB_BASE}/static-routes" ;; updateip) oiface=$2 niface=$3 - cat $CTDB_BASE/static-routes | egrep "^$niface " | while read IFACE DEST GW; do - ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null - done - cat $CTDB_BASE/static-routes | egrep "^$oiface " | while read IFACE DEST GW; do - ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null - done + while read iface dest gw; do + if [ "$niface" = "$iface" -o "$oiface" = "$iface" ] ; then + ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1 + fi + done <"${CTDB_BASE}/static-routes" ;; *) |