]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/35network-legacy/parse-team.sh
network-legacy: split off from network module
[thirdparty/dracut.git] / modules.d / 35network-legacy / parse-team.sh
1 #!/bin/sh
2 #
3 # Format:
4 # team=<teammaster>:<teamslaves>
5 #
6 # teamslaves is a comma-separated list of physical (ethernet) interfaces
7 #
8
9 parseteam() {
10 local v=${1}:
11 set --
12 while [ -n "$v" ]; do
13 set -- "$@" "${v%%:*}"
14 v=${v#*:}
15 done
16
17 case $# in
18 2) teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;;
19 *) die "team= requires two parameters" ;;
20 esac
21 return 0
22 }
23
24 for team in $(getargs team); do
25 [ "$team" = "team" ] && continue
26
27 unset teammaster
28 unset teamslaves
29
30 parseteam "$team" || continue
31
32 echo "teammaster=$teammaster" > /tmp/team.${teammaster}.info
33 echo "teamslaves=\"$teamslaves\"" >> /tmp/team.${teammaster}.info
34
35 if ! [ -e /etc/teamd/${teammaster}.conf ]; then
36 warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using activebackup."
37 mkdir -p /etc/teamd
38 printf -- "%s" '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' > "/etc/teamd/${teammaster}.conf"
39 fi
40 done
41