mirror of
https://github.com/femtofox/femtofox.git
synced 2026-10-25 18:40:20 -04:00
Network failover
This commit is contained in:
parent
9aabaad7d5
commit
883d57a3e7
2 changed files with 17 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <<EOF >> /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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue