ctdb-scripts: Quote some variable expansions
[nivanova/samba-autobuild/.git] / ctdb / config / events.d / 13.per_ip_routing
index 60c1dd08edd21ad5afb3c695f1f97d649272a66f..20f9085383e74c13231b983cbac3c4ca25c09d6e 100755 (executable)
@@ -1,9 +1,10 @@
 #!/bin/sh
 
 [ -n "$CTDB_BASE" ] || \
-    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+
+. "${CTDB_BASE}/functions"
 
-. $CTDB_BASE/functions
 loadconfig
 
 service_name=per_ip_routing
@@ -95,7 +96,7 @@ ipv4_host_addr_to_net ()
 
 ensure_rt_tables ()
 {
-    rt_tables="$CTDB_ETCDIR/iproute2/rt_tables"
+    rt_tables="$CTDB_SYS_ETCDIR/iproute2/rt_tables"
 
     # This file should always exist.  Even if this didn't exist on the
     # system, adding a route will have created it.  What if we startup
@@ -266,7 +267,7 @@ EOF
     # is invalid.  Therefore, go to a little bit of trouble to indent
     # the failure message so that it is associated with the above
     # warning message and doesn't look too nasty.
-    ip route flush table $_table_id 2>&1 | sed -e 's@^.@  &@'
+    ip route flush table "$_table_id" 2>&1 | sed -e 's@^.@  &@'
 }
 
 ######################################################################
@@ -292,7 +293,7 @@ flush_rules_and_routes ()
 # routes.
 add_missing_routes ()
 {
-    ctdb ip -v -X | {
+    $CTDB ip -v -X | {
        read _x # skip header line
 
        # Read the rest of the lines.  We're only interested in the
@@ -319,7 +320,7 @@ add_missing_routes ()
 remove_bogus_routes ()
 {
     # Get a IPs current hosted by this node, each anchored with '@'.
-    _ips=$(ctdb ip -v -X | awk -F'|' 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
+    _ips=$($CTDB ip -v -X | awk -F'|' 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
 
     ip rule show |
     while read _p _x _i _x _t ; do
@@ -382,7 +383,7 @@ case "$1" in
        # flush our route cache
        set_proc sys/net/ipv4/route/flush 1
 
-       ctdb gratiousarp "$ip" "$iface"
+       $CTDB gratiousarp "$ip" "$iface"
        ;;
 
     updateip)
@@ -397,7 +398,7 @@ case "$1" in
        # flush our route cache
        set_proc sys/net/ipv4/route/flush 1
 
-       ctdb gratiousarp "$ip" "$niface"
+       $CTDB gratiousarp "$ip" "$niface"
        tickle_tcp_connections "$ip"
        ;;