Eventscripts: 11.natgw $CTDB_NATGW_PUBLIC_IP splitting optimisation
authorMartin Schwenke <martin@meltin.net>
Tue, 17 Jul 2012 05:21:10 +0000 (15:21 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 26 Jul 2012 11:14:57 +0000 (21:14 +1000)
$CTDB_NATGW_PUBLIC_IP can be split into $_ip and $_maskbits without
forking lots of processes.

Also "local" isn't supported by POSIX.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/events.d/11.natgw

index 509375231a2ee814c870708b0bf97919f4d71e0b..f6164cf88bdef1a7075258ab1e0f5325117d6422 100755 (executable)
@@ -18,8 +18,8 @@ else
 fi
 
 delete_all() {
-       local _ip=`echo $CTDB_NATGW_PUBLIC_IP | cut -d '/' -f1`
-       local _maskbits=`echo $CTDB_NATGW_PUBLIC_IP | cut -d '/' -f2`
+       _ip="${CTDB_NATGW_PUBLIC_IP%/*}"
+       _maskbits="${CTDB_NATGW_PUBLIC_IP#*/}"
 
        [ -z "$CTDB_NATGW_PUBLIC_IFACE" ] || {
            delete_ip_from_iface $CTDB_NATGW_PUBLIC_IFACE $_ip $_maskbits 2>/dev/null