mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
Restore S30eth
The new script has rendered the static address unavailable; reverting to the previous version.
This commit is contained in:
@@ -14,20 +14,22 @@ start() {
|
||||
if [ -e /boot/eth.nodhcp ]
|
||||
then
|
||||
[ -e /boot/eth.nodhcp ] &&
|
||||
while read -r inet gw; do
|
||||
cat /boot/eth.nodhcp | while read inet gw
|
||||
do
|
||||
addr=${inet%/*}
|
||||
netid=${inet#*/}
|
||||
|
||||
if [ -z "$gw" ]; then
|
||||
IFS='.' read -r a b c d <<< "$addr"
|
||||
gw=$(( (((((($a << 8) + $b) << 8) + $c) << 8) + $d) & (((1 << $netid) - 1) << (32 - $netid)) ))
|
||||
gw=$(( (gw >> 24) & 0xff )).$(( (gw >> 16) & 0xff )).$(( (gw >> 8) & 0xff )).$(( 1 + (gw & 0xff) ))
|
||||
fi
|
||||
[ -z $gw ] &&
|
||||
gw=$( echo $addr| ( IFS='.' read a b c d; echo $((
|
||||
(((((($a<<8)+$b)<<8)+$c)<<8)+$d)
|
||||
& (((1<<$netid)-1)<<(32-$netid))
|
||||
))
|
||||
)) &&
|
||||
gw=$(($gw>>24&0xff)).$(($gw>>16&0xff)).$(($gw>>8&0xff)).$((1+( $gw>>0&0xff )))
|
||||
|
||||
arping -Dqc2 -Ieth0 $addr || continue
|
||||
ip a add $inet brd + dev eth0
|
||||
ip r add default via $gw dev eth0
|
||||
cat > /etc/resolv.conf << EOF
|
||||
cat > /etc/resolve.conf << EOF
|
||||
nameserver $gw
|
||||
nameserver 8.8.8.8
|
||||
nameserver 114.114.114.114
|
||||
@@ -51,7 +53,7 @@ EOF
|
||||
}
|
||||
stop() {
|
||||
[[ ! -e "/run/udhcpc.eth0.pid" ]] && echo "udhcpc is not running..." && exit 1
|
||||
kill "$(cat /run/udhcpc.eth0.pid)"
|
||||
kill `cat /run/udhcpc.eth0.pid`
|
||||
rm /run/udhcpc.eth0.pid
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user