linkpi_firmware_history/rootfs/link/shell/dhcp.sh

27 lines
652 B
Bash
Raw 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
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