Created
February 5, 2009 20:28
-
-
Save bhenderson/58978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a partial of a script that does my setup-routing. I needed to modify it to accept parameters. | |
# performs round-robin like link assignment | |
# args processing | |
function echo_usage { | |
echo "Usage: `basename $0` [link]* (defaults to last run params if exists, or ppp101 ppp102)" | |
} | |
if [ "$1" == "-h" ] | |
echo_usage | |
exit 1 | |
fi | |
#get last run params | |
srparams=/etc/setup-routing.params | |
if [ -s $srparams ] | |
link_array=(`cat $srparams`) | |
else | |
link_array=(ppp101 ppp102) | |
fi | |
if [ $# -gt 0 ] | |
link_array=($@) | |
fi | |
#link_array=(ppp101 ppp102 dsl1 covad0 covad) | |
len=${#link_array[@]} | |
rt_table='/etc/iproute2/rt_tables' | |
link_array=(${link_array[@]/dsl/ppp10}) | |
#check if valid input, else exit | |
count=0 | |
while [ $count -lt $len ];do | |
if ! grep -q "[ ]${link_array[$count]}$" $rt_table; then | |
exit 1 | |
#unset link_array[$count] | |
#echo "$tmplink is not a valid link" | |
#len=$(( $len -1 )) | |
fi | |
count=$(( $count + 1 )) | |
done | |
#save last run params | |
echo ${link_array[$@]} > $srparams | |
...setup routing code | |
prefix=192.168.1 | |
prio=200 | |
for n in `seq 1 199` `seq 211 253`; do | |
let id=(( ($n-1) % $len )) | |
$ip rule add pref $((prio++)) from $prefix.$n table ${link_array[$id]} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment