From 387281fae46cbc3fa5355a939ad40c2552ecdede Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 27 Apr 2018 10:53:45 +0200 Subject: [PATCH] Add configuration for deterministic network interface names Signed-off-by: David Oberhollenzer --- board/alix/ifrename | 2 ++ board/rpi3/ifrename | 2 ++ pkg/init/build | 6 ++++++ util/misc.sh | 19 ++++++++++++++----- 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 board/alix/ifrename create mode 100644 board/rpi3/ifrename diff --git a/board/alix/ifrename b/board/alix/ifrename new file mode 100644 index 0000000..b00e8c6 --- /dev/null +++ b/board/alix/ifrename @@ -0,0 +1,2 @@ +# Rename ALIX board interfaces to port0...port2 +eth*,00:0d:b9:*,port \ No newline at end of file diff --git a/board/rpi3/ifrename b/board/rpi3/ifrename new file mode 100644 index 0000000..6ed855b --- /dev/null +++ b/board/rpi3/ifrename @@ -0,0 +1,2 @@ +# Rename Raspberry Pi ethernet interfaces to port +eth*,b8:27:eb:*,port \ No newline at end of file diff --git a/pkg/init/build b/pkg/init/build index 8b695d1..84ad276 100755 --- a/pkg/init/build +++ b/pkg/init/build @@ -39,6 +39,12 @@ deploy() { ln -s "/share/init/hwclock" "$DEPLOY/etc/init.d/hwclock" fi + svc=$(file_path_override "ifrename") + if [ ! -z "$svc" ]; then + cp "$svc" "$DEPLOY/etc/netcfg/ifrename" + ln -s "/share/init/ifrename" "$DEPLOY/etc/init.d/ifrename" + fi + for svc in $GETTY_TTY; do ln -s "/share/init/agetty" "$DEPLOY/etc/init.d/agetty@$svc" done diff --git a/util/misc.sh b/util/misc.sh index 008f812..7967061 100644 --- a/util/misc.sh +++ b/util/misc.sh @@ -1,20 +1,29 @@ -cat_file_override() { +file_path_override() { local fname="$1" if [ -e "$SCRIPTDIR/product/$PRODUCT/${fname}.${BOARD}" ]; then - cat "$SCRIPTDIR/product/$PRODUCT/${fname}.${BOARD}" + echo "$SCRIPTDIR/product/$PRODUCT/${fname}.${BOARD}" return fi if [ -e "$SCRIPTDIR/product/$PRODUCT/$fname" ]; then - cat "$SCRIPTDIR/product/$PRODUCT/$fname" + echo "$SCRIPTDIR/product/$PRODUCT/$fname" return fi if [ -e "$SCRIPTDIR/board/$BOARD/$fname" ]; then - cat "$SCRIPTDIR/board/$BOARD/$fname" + echo "$SCRIPTDIR/board/$BOARD/$fname" return fi if [ -e "$SCRIPTDIR/product/common/$fname" ]; then - cat "$SCRIPTDIR/product/common/$fname" + echo "$SCRIPTDIR/product/common/$fname" + return + fi +} + +cat_file_override() { + local path=$(file_path_override "$1") + + if [ ! -z "$path" ]; then + cat "$path" fi }