From 883d57a3e734e5f2963a34ddd8b79d0fde7c0b01 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 19 Feb 2025 13:24:32 +0200 Subject: [PATCH] Network failover --- .../rootfs_uclibc_rv1106/etc/network/interfaces | 9 +++++++++ .../usr/local/bin/femto-runonce.sh | 16 ++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/network/interfaces b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/network/interfaces index 315112b..bfde602 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/network/interfaces +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/network/interfaces @@ -8,4 +8,13 @@ iface lo inet loopback allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf + metric 100 + post-up sleep 5 && dhclient wlan0 + pre-down ip route del default via $(ip route | awk '/default/ {print $3}') dev wlan0 metric 100 + +allow-hotplug eth0 +iface eth0 inet dhcp + metric 10 + post-up ip route replace default via $(ip route | awk '/default/ {print $3}') dev eth0 metric 10 + pre-down ip route del default via $(ip route | awk '/default/ {print $3}') dev eth0 metric 10 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index 4ba57a2..8f6073b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -70,16 +70,16 @@ fi # prevent randomized mac address for eth0. If `eth0`` is already present in /etc/network/interfaces, skip mac="$(awk '/Serial/ {print $3}' /proc/cpuinfo | tail -c 11 | sed 's/^\(.*\)/a2\1/' | sed 's/\(..\)/\1:/g;s/:$//')" -if ! grep -q "eth0" /etc/network/interfaces; then +file="/etc/network/interfaces" +if ! grep -q " hwaddress ether $mac" "$file"; then log_message "Setting eth0 MAC address to $mac (derivative of CPU s/n)" - cat <> /etc/network/interfaces -# static mac address for onboard ethernet (castellated pins) -allow-hotplug eth0 -iface eth0 inet dhcp -hwaddress ether $mac -EOF + awk -v mac="$mac" ' + { print } + /allow-hotplug eth0/ { count=5 } + count && --count == 0 { print " hwaddress ether " mac } + ' "$file" > "$file.tmp" && mv "$file.tmp" "$file" else - log_message "eth0 already exists in /etc/network/interfaces, skipping" + log_message "eth0 mac address already set in /etc/network/interfaces, skipping" fi # Add term stuff to .bashrc