aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-07-12 23:40:07 +0200
committerThomas Deutschmann <whissi@gentoo.org>2019-07-14 13:58:02 +0200
commit8a719bc992a06e9b78145bf417e68c84926686a3 (patch)
tree743ebf6b8c7bab5ff9ee0997bd71f6ee7def33e6 /defaults/udhcpc.scripts
parentgen_compile.sh: Refactor compile_gen_init_cpio() (diff)
downloadgenkernel-8a719bc992a06e9b78145bf417e68c84926686a3.tar.gz
genkernel-8a719bc992a06e9b78145bf417e68c84926686a3.tar.bz2
genkernel-8a719bc992a06e9b78145bf417e68c84926686a3.zip
Refactor udhcpc.scripts
- Reformatted. - "leasefail" action added. - "nak" action added. Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'defaults/udhcpc.scripts')
-rw-r--r--[-rwxr-xr-x]defaults/udhcpc.scripts41
1 files changed, 31 insertions, 10 deletions
diff --git a/defaults/udhcpc.scripts b/defaults/udhcpc.scripts
index 53aa2cc..a7a4a52 100755..100644
--- a/defaults/udhcpc.scripts
+++ b/defaults/udhcpc.scripts
@@ -1,18 +1,24 @@
#!/bin/sh
-[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+if [ -z "$1" ]
+then
+ echo "Error: should be called from udhcpc"
+ exit 1
+fi
case ${1} in
- renew|bound)
- [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
- [ -n "$subnet" ] && NETMASK="netmask $subnet"
- [ -n "$rootpath" ] && echo "$rootpath" > /rootpath
- [ -n "$hostname" ] && hostname ${hostname}
+ bound|renew)
+ [ -n "$broadcast" ] && BROADCAST="broadcast ${broadcast}"
+ [ -n "$subnet" ] && NETMASK="netmask ${subnet}"
+ [ -n "$rootpath" ] && echo "${rootpath}" > /rootpath
+ [ -n "$hostname" ] && hostname "${hostname}"
+
+ busybox ifconfig "${interface}" ${ip} ${BROADCAST} ${NETMASK}
- busybox ifconfig $interface $ip $BROADCAST $NETMASK
if [ -n "${router}" ]
then
- while route del default gw 0.0.0.0 dev $interface; do
+ while busybox route del default gw 0.0.0.0 dev "${interface}" >/dev/null 2>&1
+ do
:
done
@@ -21,7 +27,9 @@ case ${1} in
busybox route add default gw ${i}
done
fi
+
[ -n "$domain" ] && echo "domain ${domain}" >> /etc/resolv.conf
+
if [ -n "${dns}" ]
then
for i in ${dns}
@@ -30,8 +38,21 @@ case ${1} in
done
fi
;;
- deconfig)
- busybox ifconfig $interface 0.0.0.0
+ deconfig|leasefail)
+ busybox ifconfig "${interface}" 0.0.0.0
+ while busybox route del default dev "${interface}" >/dev/null 2>&1
+ do
+ :
+ done
+ ;;
+ nak)
+ echo "nak: ${message}"
+ ;;
+ *)
+ echo "unknown option $1" >&2
+ echo "Usage: $0 {bound|deconfig|leasefail|nak|renew}" >&2
+ exit 1
;;
esac
+exit 0