scripts: Only write to /proc route flush files if they exist
authorMartin Schwenke <martin@meltin.net>
Wed, 24 Jun 2015 11:06:22 +0000 (21:06 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 24 Feb 2016 10:44:27 +0000 (21:44 +1100)
On IPv4-only or IPv6-only systems one of these files will not exist.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 0c609c95051ff8c1e8fd61acc6abc7e4b4c4441b)

config/functions
tests/eventscripts/etc-ctdb/rc.local

index 031d59ddbcf2f6aaefbfdae0d71e993594fbdd91..d4209cbe76438cea11135426c01429d013e67b4a 100644 (file)
@@ -233,6 +233,13 @@ set_proc ()
     echo "$2" >"/proc/$1"
 }
 
+set_proc_maybe ()
+{
+    if [ -w "/proc/$1" ] ; then
+       set_proc "$1" "$2"
+    fi
+}
+
 ######################################################
 # wrapper around getting file contents from /proc/ to allow
 # this to be hooked for testing
@@ -989,8 +996,8 @@ drop_all_public_ips ()
 
 flush_route_cache ()
 {
-    set_proc sys/net/ipv4/route/flush 1
-    set_proc sys/net/ipv6/route/flush 1
+    set_proc_maybe sys/net/ipv4/route/flush 1
+    set_proc_maybe sys/net/ipv6/route/flush 1
 }
 
 ########################################################
index 0291e574589fe1e307c5a1526b333d76445c873e..0932ab4ad03330c13bd01610140cbd568e9e51fd 100755 (executable)
@@ -23,6 +23,7 @@ nice_service ()
 
 # Always succeeds
 set_proc () { : ; }
+set_proc_maybe () { : ; }
 
 get_proc ()
 {