summaryrefslogtreecommitdiffstats
path: root/src/initramfs/stage3-stuff/bin/dhcpmkconfig
diff options
context:
space:
mode:
Diffstat (limited to 'src/initramfs/stage3-stuff/bin/dhcpmkconfig')
-rwxr-xr-xsrc/initramfs/stage3-stuff/bin/dhcpmkconfig47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/initramfs/stage3-stuff/bin/dhcpmkconfig b/src/initramfs/stage3-stuff/bin/dhcpmkconfig
new file mode 100755
index 00000000..fa01db75
--- /dev/null
+++ b/src/initramfs/stage3-stuff/bin/dhcpmkconfig
@@ -0,0 +1,47 @@
+#!/bin/sh
+# Copyright (c) 2003..2006 - RZ Uni Freiburg
+# Copyright (c) 2006..2010 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found under http://openslx.org
+#
+# Universal (distro independent) IP configuration writer for busybox udhcpc
+# applet used within OpenSLX initramfs. The result is written to the
+# /etc/initramfs-setup file
+
+# script started twice by udhcpc, quit fast if no ip configuration present
+[ -z "$ip" ] && exit 0
+
+# heavy debugging output in level 3 and above ... and on 13
+#FIXME: DEBUGLEVEL is not propagated to this file (at least for Ubuntu)
+[ -z "$DEBUGLEVEL" ] && DEBUGLEVEL=0
+[ $DEBUGLEVEL -gt 3 -a $DEBUGLEVEL -lt 8 -o $DEBUGLEVEL -eq 13 ] && \
+ set -x
+
+echo -e "# network configuration written by $0:" >/tmp/confviadhcp
+unset HOME IFS KCMDLINE DEBUGLEVEL MODPRV TERM BOOTIF BOOT_IMAGE \
+ infomsg mask lease interface cfgmsg cfgfile boot_file no_bootsplash
+# set the broadcast address if not delivered by dhcp
+[ -z "$broadcast" ] && \
+ broadcast=$(ipcalc -b $ip/$subnet|sed s/.*=//)
+set | sed \
+ -e "s,^P.*,,;s,ntpsrv,ntp_servers,;s,ip,clientip," \
+ -e "s,serverid,serverip,;s,subnet,subnet_mask," \
+ -e "s,router,gateway,;s,hostname,host_name," \
+ -e "s,domain,domain_name,;s,dns,domain_name_servers," \
+ -e "s,broadcast,broadcast_address,;s,dhc.*,,;/^$/d" \
+ -e "s,nissrv,nis_servers,;s,nisdomain_name,nis_domain," \
+ -e "s,wins,netbios_name_servers,;/OPTIND.*/d" >>/tmp/confviadhcp
+
+# generate a local /etc/resolv.conf (might overwrite the version from preboot)
+[ -n "$domain" ] && echo -e "search $domain\n" >/etc/resolv.conf
+test -n "$dns" && {
+ for name in $dns; do
+ echo nameserver $name >>/etc/resolv.conf;
+ done; }
+