hw-test/scripts/setup-bonding-degraded

56 lines
758 B
Text
Raw Normal View History

2017-01-26 21:43:03 -06:00
#!/bin/bash
source scan-netdev
sleep_5 () {
for WAIT in 1 2 3 4 5 ; do
echo -n '.'
sleep 1
done
echo
}
case "$1" in
"1")
SLAVE_NO=1
;;
"2")
SLAVE_NO=2
;;
*)
echo "usage: $0 <1|2> <up|down>"
exit 28
;;
esac
case "$2" in
"up")
echo -n "Inserting slave $SLAVE_NO..."
ACTION=
;;
"down")
echo -n "Removing slave $SLAVE_NO..."
ACTION="-d"
;;
*)
echo "usage: $0 <1|2> <up|down>"
exit 29
;;
esac
for BOND_N in {0..4} ; do
BOND=bond$BOND_N
[[ -d /sys/class/net/$BOND ]] || continue
if [[ ! -f $OUTPUT_DIR/netdev/$BOND.slaves ]] ; then
echo "Missing slaves cache file"
exit 30
fi
SLAVE=`cut -d ' ' -f $SLAVE_NO \
$OUTPUT_DIR/netdev/$BOND.slaves`
ifenslave $ACTION $BOND $SLAVE
echo -n " $? "
done
echo