blob: 83badc9980a8a2355fa6b99a6704feaccb234e79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/bin/sh
#
# Format:
# team=<teammaster>:<teamslaves>[:<teamrunner>]
#
# teamslaves is a comma-separated list of physical (ethernet) interfaces
# teamrunner is the runner type to be used (see teamd.conf(5)); defaults to activebackup
#
# team without parameters assumes team=team0:eth0,eth1:activebackup
#
parseteam() {
local v="${1}":
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
v=${v#*:}
done
case $# in
0)
teammaster=team0
teamslaves="eth0 eth1"
teamrunner="activebackup"
;;
1)
teammaster=$1
teamslaves="eth0 eth1"
teamrunner="activebackup"
;;
2)
teammaster=$1
teamslaves=$(str_replace "$2" "," " ")
teamrunner="activebackup"
;;
3)
teammaster=$1
teamslaves=$(str_replace "$2" "," " ")
teamrunner=$3
;;
*) die "team= requires zero to three parameters" ;;
esac
return 0
}
for team in $(getargs team); do
[ "$team" = "team" ] && continue
unset teammaster
unset teamslaves
unset teamrunner
parseteam "$team" || continue
{
echo "teammaster=$teammaster"
echo "teamslaves=\"$teamslaves\""
echo "teamrunner=\"$teamrunner\""
} > /tmp/team."${teammaster}".info
if ! [ -e /etc/teamd/"${teammaster}".conf ]; then
warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using $teamrunner."
mkdir -p /etc/teamd
printf -- "%s" "{\"runner\": {\"name\": \"$teamrunner\"}, \"link_watch\": {\"name\": \"ethtool\"}}" > "/tmp/${teammaster}.conf"
fi
done
|