From 3191ec7ccedbf7265a409a314513cef5a8143495 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 25 Jul 2016 16:28:57 +0200 Subject: var_service/fw: optionally flush all netdevs; optionally prefer one 0/0 routing Signed-off-by: Denys Vlasenko --- examples/var_service/fw/run | 48 +++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'examples/var_service') diff --git a/examples/var_service/fw/run b/examples/var_service/fw/run index 81c7f2e7c..871a70545 100755 --- a/examples/var_service/fw/run +++ b/examples/var_service/fw/run @@ -1,18 +1,20 @@ #!/bin/bash # (using bashism: arrays) -service="${PWD##*/}" -rundir="/var/run/service/$service" - -user=root -extif=if -ext_open_tcp="21 22 80" # space-separated +user="root" +reset_all_netdevs=true +preferred_default_route_iface="if" +extif="if" +ext_open_tcp="22 80 88" # space-separated # Make ourself one-shot sv o . # Debug #date '+%Y-%m-%d %H:%M:%S' >>"$0.log" +service=`basename $PWD` +rundir="/var/run/service/$service" + ### filter This is the default table (if no -t option is passed). It contains ### the built-in chains INPUT (for packets coming into the box itself), ### FORWARD (for packets being routed through the box), and OUTPUT (for @@ -70,7 +72,6 @@ ln -s "$rundir" rundir # Timestamping date '+%Y-%m-%d %H:%M:%S' - echo; echo "* Reading IP config" cfg=-1 # static cfg dhcp,zeroconf etc @@ -86,11 +87,19 @@ echo; echo "* Configuring hardware" #doit ethtool -K if rx off tx off sg off tso off echo; echo "* Resetting address and routing info" -doit ip a f dev lo -i=0; while test "${if[$i]}"; do - doit ip a f dev "${if[$i]}" - doit ip r f dev "${if[$i]}" root 0/0 -let i++; done +if $reset_all_netdevs; then + devs=`sed -n 's/ //g;s/:.*$//p'