You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.0 KiB
56 lines
2.0 KiB
![]()
15 years ago
|
#!/bin/sh
|
||
|
#
|
||
|
# Format:
|
||
![]()
8 years ago
|
# bond=<bondname>[:<bondslaves>[:<options>[:<mtu>]]]
|
||
![]()
15 years ago
|
#
|
||
|
# bondslaves is a comma-separated list of physical (ethernet) interfaces
|
||
|
# options is a comma-separated list on bonding options (modinfo bonding for details) in format compatible with initscripts
|
||
|
# if options include multi-valued arp_ip_target option, then its values should be separated by semicolon.
|
||
|
#
|
||
|
# bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
|
||
|
#
|
||
![]()
9 years ago
|
# if the mtu is specified, it will be set on the bond master
|
||
|
#
|
||
![]()
15 years ago
|
|
||
![]()
8 years ago
|
# We translate list of slaves to space-separated here to make it easier to loop over them in ifup
|
||
![]()
15 years ago
|
# Ditto for bonding options
|
||
|
parsebond() {
|
||
|
local v=${1}:
|
||
|
set --
|
||
|
while [ -n "$v" ]; do
|
||
|
set -- "$@" "${v%%:*}"
|
||
|
v=${v#*:}
|
||
|
done
|
||
|
|
||
|
case $# in
|
||
|
0) bondname=bond0; bondslaves="eth0 eth1" ;;
|
||
|
1) bondname=$1; bondslaves="eth0 eth1" ;;
|
||
![]()
13 years ago
|
2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
|
||
|
3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
|
||
![]()
9 years ago
|
4) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " "); bondmtu=$4;;
|
||
![]()
15 years ago
|
*) die "bond= requires zero to four parameters" ;;
|
||
|
esac
|
||
|
}
|
||
|
|
||
![]()
9 years ago
|
# Parse bond for bondname, bondslaves, bondmode, bondoptions and bondmtu
|
||
![]()
9 years ago
|
for bond in $(getargs bond=); do
|
||
|
unset bondname
|
||
|
unset bondslaves
|
||
|
unset bondoptions
|
||
![]()
9 years ago
|
unset bondmtu
|
||
![]()
9 years ago
|
if [ "$bond" != "bond" ]; then
|
||
|
parsebond "$bond"
|
||
![]()
15 years ago
|
fi
|
||
|
# Simple default bond
|
||
|
if [ -z "$bondname" ]; then
|
||
|
bondname=bond0
|
||
|
bondslaves="eth0 eth1"
|
||
|
fi
|
||
|
# Make it suitable for initscripts export
|
||
![]()
13 years ago
|
bondoptions=$(str_replace "$bondoptions" ";" ",")
|
||
![]()
12 years ago
|
echo "bondname=$bondname" > /tmp/bond.${bondname}.info
|
||
|
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
|
||
|
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
|
||
![]()
9 years ago
|
echo "bondmtu=\"$bondmtu\"" >> /tmp/bond.${bondname}.info
|
||
![]()
9 years ago
|
done
|