#!/bin/sh # Copyright (c) 2003 - 2006 - RZ Uni Freiburg # Copyright (c) 2006, 2007 - 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 several dhcp # clients used within OpenSLX initramfs. The result is written in unified # form to the /etc/machine-setup file # client variable should be exported via calling function cfgfile="/tmp/confviadhcp" cfgmsg="\n## Configuration written by $0" infomsg="# --> You are using $dhcl. With this client you are not \ able to\n# transfer any vendor specific, self defined dhcp options. If \ this is\n# intended, use dhclient instead or get them via tftp (to be \ enabled\n# via kernel command line)." # 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 case $0 in *dhcpcd*) dhcl="dhcpcd"; echo -e "$cfgmsg\n$infomsg" >>/tmp/confviadhcp sed -e "s,',\",g;s,IPADDR,clientip,;s,NETMASK,subnet_mask," \ -e "s,GATEWAY,gateway,;s,BROADCAST,broadcast_address," \ -e "s,HOSTNAME,host_name,;s,DOMAIN,domain_name," \ -e "/=[^']/s/=\(.*\)/='\1'/;/DNS/s/,/ /;/NTPSERVERS/s/,/ /" \ -e "s,ROOTPATH,root_path,;s,DNS,domain_name_servers," \ -e "s,NTPSERVERS,ntp_servers,;s,DHCPSID,serverip," \ -e "s,WINSSERVERS,netbios_name_servers," \ -e "s,NETWORK,network," \ -e "s,DHCP..ADDR.*,,;s,.*TIME=.*,,;s,CL.*,,;/^$/d" \ -e "s,INTER.*,,;s,DHCPSNAME.*,," /var/lib/dhcp/dhcpcd-eth0.info \ >>$cfgfile ;; *dhclient*) if [ $reason = "BOUND" ] ; then echo -e "$cfgmsg\n# --> You are using dhclient. If you wish to \ transfer other vendor/user\n# specific variables, you have to add \ them in functions and in\n# dhcpmkconfig script or use tftp (to be \ enabled via kernel command\n# line)." >>$cfgfile set | sed -n -e '/^new/p' | sed \ -e "s,^new_,,;s,fixed_address,clientip," \ -e "s,routers,gateway,;s,dhcp_server_identifier,serverip," \ -e "s,.*_t[iy][mp]e.*,,;s,.*_message_.*,,;/^$/d" \ -e "s,language=,country=,;s,ip_address,clientip," \ >>$cfgfile fi ;; *udhcpc*) dhcl="udhcpc"; echo -e "$cfgmsg\n$infomsg" >>$cfgfile # if $cfgfile is changed change target for set output accordingly unset infomsg HOME IFS mask lease interface cfgmsg cfgfile unset DEBUGLEVEL 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 "/OPTIND.*/d" \ >>/tmp/confviadhcp ;; esac