Skip to content

Commit ae085b0

Browse files
alpine-host-entrypoint-update (#5)
Update alpine host entrypoint.sh script
1 parent 59b94fb commit ae085b0

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

alpine_host/entrypoint.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,30 @@
33
UPLINK='eth'
44

55
# TMODE is expected to be set via the containerlab topology file prior to deployment
6-
# Expected values are "lacp" and "static" which will bond eth1 and eth2
6+
# Expected values are "lacp" or "static" or "active-backup" which will bond eth1 and eth2
77
if [ -z "$TMODE" ]; then
88
TMODE='none'
99
fi
1010

11+
# TACTIVE and TBACKUP to be set via the containerlab topology file for active-backup runner
12+
# expected values are "eth1" or "eth2" default is "eth1" active and "eth2" backup
13+
if [ -z "$TACTIVE" ]; then
14+
TACTIVE='eth1'
15+
TBACKUP='eth2'
16+
elif [ "$TACTIVE" == 'eth1' ]; then
17+
TBACKUP='eth2'
18+
elif [ "$TACTIVE" == 'eth2' ]; then
19+
TBACKUP='eth1'
20+
fi
21+
1122
echo "teaming mode is " $TMODE
1223

1324
#######################
1425
# Re-run script as sudo
1526
#######################
1627

1728
if [ "$(id -u)" != "0" ]; then
18-
exec sudo --preserve-env=TMODE "$0" "$@"
29+
exec sudo --preserve-env=TMODE,TACTIVE,TBACKUP "$0" "$@"
1930
fi
2031

2132
##########################
@@ -78,13 +89,31 @@ cat << EOF > /home/alpine/teamd-static.conf
7889
}
7990
EOF
8091

92+
cat << EOF > /home/alpine/teamd-active-backup.conf
93+
{
94+
"device": "team0",
95+
"runner": {"name": "activebackup"},
96+
"link_watch": {"name": "ethtool"},
97+
"ports": {
98+
"$TACTIVE": {
99+
"prio": 100
100+
},
101+
"$TBACKUP": {
102+
"prio": -10
103+
}
104+
}
105+
}
106+
EOF
107+
81108
if [ "$TMODE" == 'lacp' ]; then
82109
TARG='/home/alpine/teamd-lacp.conf'
83110
elif [ "$TMODE" == 'static' ]; then
84111
TARG='/home/alpine/teamd-static.conf'
112+
elif [ "$TMODE" == 'active-backup' ]; then
113+
TARG='/home/alpine/teamd-active-backup.conf'
85114
fi
86115

87-
if [ "$TMODE" == 'lacp' ] || [ "$TMODE" == 'static' ]; then
116+
if [ "$TMODE" == 'lacp' ] || [ "$TMODE" == 'static' ] || [ "$TMODE" == 'active-backup' ]; then
88117
teamd -v
89118
teamd -k -f $TARG
90119
ip link set eth1 down

0 commit comments

Comments
 (0)