File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,6 +123,10 @@ sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/arista-
123123sudo cp files/initramfs-tools/mke2fs $FILESYSTEM_ROOT /etc/initramfs-tools/hooks/mke2fs
124124sudo chmod +x $FILESYSTEM_ROOT /etc/initramfs-tools/hooks/mke2fs
125125
126+ # Hook into initramfs: rename the management interfaces on arista switches
127+ sudo cp files/initramfs-tools/arista-net $FILESYSTEM_ROOT /etc/initramfs-tools/scripts/init-premount/arista-net
128+ sudo chmod +x $FILESYSTEM_ROOT /etc/initramfs-tools/scripts/init-premount/arista-net
129+
126130# # Hook into initramfs: after partition mount and loop file mount
127131# # 1. Prepare layered file system
128132# # 2. Bind-mount docker working directory (docker aufs cannot work over aufs rootfs)
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ case $1 in
4+ prereqs)
5+ exit 0
6+ ;;
7+ esac
8+
9+ set -e
10+
11+ # Extract kernel parameters
12+ set -- $( cat /proc/cmdline)
13+ items=" "
14+ for x in " $@ " ; do
15+ case " $x " in
16+ Aboot=* )
17+ aboot_flag=" ${x# Aboot=} "
18+ ;;
19+ net_* )
20+ item=" ${x# net_} "
21+ items=" $items $item "
22+ ;;
23+ platform=* )
24+ platform_flag=" ${x# platform=} "
25+ ;;
26+ esac
27+ done
28+
29+ arista_net_rename () {
30+ local device_path=" $1 "
31+ local new_name=" $2 "
32+ local from_name=" $3 "
33+ for path in $( ls -d /sys/class/net/$from_name * 2> /dev/null) ; do
34+ local devid=" $( realpath " $path /device" ) "
35+ if echo " $devid " | grep -q " $device_path " ; then
36+ local cur_name=" ${path##*/ } "
37+ ip link set " $cur_name " name " $new_name "
38+ return
39+ fi
40+ done
41+ }
42+
43+ # Iterate over all the net_maX items found in the cmdline two times.
44+ # First time renaming the interfaces to maX.
45+ # The second time renaming them to their final name ethX.
46+ if [ -n " $aboot_flag " -a " $platform_flag " == ' rook' ]; then
47+ for item in $items ; do
48+ key=" ${item% =* } "
49+ value=" ${item#* =} "
50+ arista_net_rename " $value " " $key " eth
51+ done
52+ for item in $items ; do
53+ key=" ${item% =* } "
54+ value=" ${item#* =} "
55+ index=" ${key# ma} "
56+ index=" $(( $index - 1 )) "
57+ newKey=" eth$index "
58+ arista_net_rename " $value " " $newKey " ma
59+ done
60+ fi
61+
You can’t perform that action at this time.
0 commit comments