#!/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,search,domain_search," \ -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 "domain $domain" >/etc/resolv.conf if [ -n "$search" ]; then echo -e "search $search" >>/etc/resolv.conf else [ -n "$domain" ] && echo -e "search $domain" >>/etc/resolv.conf fi test -n "$dns" && { for name in $dns; do echo nameserver $name >>/etc/resolv.conf; done; } #generate local /etc/hostname echo $hostname.$domain > /etc/hostname