linkpi_firmware_history/rootfs/link/shell/dhcp.sh

28 lines
693 B
Bash
Raw Permalink Normal View History

2024-02-15 22:07:30 +01:00
#!/bin/sh
if [ $1 != "bound" ]; then
exit 0
fi
if [ "$ip" == "" ]; then
exit 0
fi
2024-02-15 22:07:50 +01:00
dns=`echo $dns |awk -F ' ' '{print $1}'`
2024-02-15 22:07:30 +01:00
echo "dhcp_result"
echo "dev:"$interface
echo "ip:"$ip
echo "mask:"$subnet
echo "gw:"$router
echo "dns:"$dns
ifconfig $interface $ip netmask $subnet up
route del default
route add default gw $router
echo nameserver $dns > /etc/resolv.conf
if [ "$interface" = "eth0" ]; then
echo '{"dhcp":true,"ip":"'$ip'","mask":"'$subnet'","gateway":"'$router'","dns":"'$dns'"}' > /link/config/net.json
echo $ip > /etc/hostname
hostname -F /etc/hostname
2024-02-15 22:07:35 +01:00
else
echo '{"dhcp":true,"ip":"'$ip'","mask":"'$subnet'","gateway":"'$router'","dns":"'$dns'"}' > /link/config/net2.json
2024-02-15 22:07:30 +01:00
fi