From f39dfd321dacd6cdde5e25f36940f1f61888f08b Mon Sep 17 00:00:00 2001 From: Trammell Hudson Date: Mon, 27 Mar 2017 15:56:10 -0400 Subject: [PATCH] enable dhcp and add helper script for lease setup --- config/busybox.config | 4 ++-- initrd/init | 2 +- initrd/sbin/config-dhcp.sh | 46 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100755 initrd/sbin/config-dhcp.sh diff --git a/config/busybox.config b/config/busybox.config index 7613685..3b05eca 100644 --- a/config/busybox.config +++ b/config/busybox.config @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.25.0 -# Mon Mar 27 14:20:49 2017 +# Mon Mar 27 14:21:05 2017 # CONFIG_HAVE_DOT_CONFIG=y @@ -909,7 +909,7 @@ CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y CONFIG_UDHCP_DEBUG=9 CONFIG_FEATURE_UDHCP_RFC3397=y CONFIG_FEATURE_UDHCP_8021Q=y -CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script" +CONFIG_UDHCPC_DEFAULT_SCRIPT="/sbin/config-dhcp.sh" CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80 CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="" # CONFIG_UDPSVD is not set diff --git a/initrd/init b/initrd/init index 08af1b9..c9b1e9e 100755 --- a/initrd/init +++ b/initrd/init @@ -1,6 +1,6 @@ #!/bin/ash # First thing it is vital to mount the /dev and other system directories -mkdir /proc /sys /dev /tmp /boot 2>&- 1>&- +mkdir /proc /sys /dev /tmp /etc /boot 2>&- 1>&- mount -t devtmpfs none /dev mount -t proc none /proc mount -t sysfs none /sys diff --git a/initrd/sbin/config-dhcp.sh b/initrd/sbin/config-dhcp.sh new file mode 100755 index 0000000..1016963 --- /dev/null +++ b/initrd/sbin/config-dhcp.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# udhcpc script + +[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 + +RESOLV_CONF="/etc/resolv.conf" +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" + +case "$1" in + deconfig) + grep -q -v ip= /proc/cmdline + if [ $? -eq 0 ]; then + /sbin/ifconfig $interface up + fi + grep -q -v nfsroot= /proc/cmdline + if [ $? -eq 0 ]; then + /sbin/ifconfig $interface 0.0.0.0 + fi + ;; + + renew|bound) + /sbin/ifconfig $interface $ip $BROADCAST $NETMASK + + if [ -n "$router" ] ; then + echo "deleting routers" + while route del default gw 0.0.0.0 dev $interface ; do + : + done + + for i in $router ; do + route add default gw $i dev $interface + done + fi + + echo -n > $RESOLV_CONF + [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF + for i in $dns ; do + echo adding dns $i + echo nameserver $i >> $RESOLV_CONF + done + ;; +esac + +exit 0