diff options
author | Dirk von Suchodoletz | 2006-07-09 19:36:29 +0200 |
---|---|---|
committer | Dirk von Suchodoletz | 2006-07-09 19:36:29 +0200 |
commit | 4c56d7ac43028110ad5d313ffa422bb226d15114 (patch) | |
tree | a43cbcbb9ea9c1da092be035597f6e3a6170ea0c | |
parent | Fix for certain keyboard (inactivity) problem, introduction of keytable (diff) | |
download | core-4c56d7ac43028110ad5d313ffa422bb226d15114.tar.gz core-4c56d7ac43028110ad5d313ffa422bb226d15114.tar.xz core-4c56d7ac43028110ad5d313ffa422bb226d15114.zip |
Added "fileget" configuration (via tftp from ~/tftpboot/client-config/*),
see BootRootVerzeichnisse and ClientConfiguration, fix for dhclient
(multiple)
config entries in machine-setup ...
git-svn-id: http://svn.openslx.org/svn/openslx/ld4@280 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r-- | initrd/distro-specs/suse/functions-default | 4 | ||||
-rwxr-xr-x | initrd/initrd-stuff/bin/dhcpmkconfig | 38 | ||||
-rw-r--r-- | initrd/initrd-stuff/etc/functions | 56 | ||||
-rwxr-xr-x | initrd/initrd-stuff/init | 18 |
4 files changed, 68 insertions, 48 deletions
diff --git a/initrd/distro-specs/suse/functions-default b/initrd/distro-specs/suse/functions-default index d3cd5dc2..eacc5b5d 100644 --- a/initrd/distro-specs/suse/functions-default +++ b/initrd/distro-specs/suse/functions-default @@ -4,11 +4,11 @@ # functions file). This file is the main base for the several # SuSE distro versions # -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 23-06-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 09-07-2006 # # Copyright: (c) 2006 - RZ Universitaet Freiburg # -# Version: 0.3.0a +# Version: 0.3.3a # empty functions are defined at the beginning of /etc/functions diff --git a/initrd/initrd-stuff/bin/dhcpmkconfig b/initrd/initrd-stuff/bin/dhcpmkconfig index 8f25f538..bddb6b23 100755 --- a/initrd/initrd-stuff/bin/dhcpmkconfig +++ b/initrd/initrd-stuff/bin/dhcpmkconfig @@ -4,15 +4,15 @@ # several dhcp clients. The result is written in unified form # to the /etc/machine-setup file # -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 03-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 09-07-2006 # Lars Mueller, 23-06-2006 # Oliver Tappe, 23-06-2006 # # Copyright: (c) 2006 - RZ Universitaet Freiburg # client variable should be exported via calling function -echo -e "\n# ip configuration written by $0" \ - >>/tmp/confviadhcp +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 \ @@ -22,7 +22,7 @@ enabled\n# via kernel command line)." set -x case $0 in *dhcpcd*) - dhcl="dhcpcd"; echo -e "$infomsg" >>/tmp/confviadhcp + 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," \ @@ -32,25 +32,27 @@ case $0 in -e "s,NETWORK,network," \ -e "s,DHCP..ADDR.*,,;s,.*TIME=.*,,;s,CL.*,,;/^$/d" \ -e "s,INTER.*,,;s,DHCPSNAME.*,," /var/lib/dhcp/dhcpcd-eth0.info \ - >>/tmp/confviadhcp + >>$cfgfile ;; *dhclient*) - echo -e "# --> You are using dhclient. Iy 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)." >>/tmp/confviadhcp - 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," \ - >>/tmp/confviadhcp + 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 ;; *pump*) - dhcl="pump"; echo -e "$infomsg" >>/tmp/confviadhcp + dhcl="pump"; echo -e "$cfgmsg\n$infomsg" >>$cfgfile ;; *udhcpc*) - dhcl="udhcpc"; echo -e "$infomsg" >>/tmp/confviadhcp + dhcl="udhcpc"; echo -e "$cfgmsg\n$infomsg" >>$cfgfile unset infomsg HOME IFS mask lease interface set | sed \ -e "s,^P.*,,;s,ntpsrv,ntp_servers,;s,ip,clientip," \ @@ -58,7 +60,7 @@ command\n# line)." >>/tmp/confviadhcp -e "s,router,gateway,;s,hostname,host_name," \ -e "s,dns,domain_name_servers,;s,domain,domain_name," \ -e "s,broadcast,broadcast_address,;s,dhc.*,,;/^$/d" \ - >>/tmp/confviadhcp + >>$cfgfile ;; esac diff --git a/initrd/initrd-stuff/etc/functions b/initrd/initrd-stuff/etc/functions index 0f07189f..2814e29c 100644 --- a/initrd/initrd-stuff/etc/functions +++ b/initrd/initrd-stuff/etc/functions @@ -2,13 +2,13 @@ # linux diskless clients (included by init, hwautocfg, # servconfig, ... within initial ramdisk) # -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 08-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 09-07-2006 # Felix Endres, 30-04-2006 # Tobias Maier # # Copyright: (c) 2006 - RZ Universitaet Freiburg # -# Version: 0.4.2e +# Version: 0.5.0b ####################################################################### # set of empty dummy functions (loaded before real functions in the @@ -165,10 +165,13 @@ case $ipcfg in if [ "$gw" != "0.0.0.0" ] ; then ip route add default via $gw fi + MAC=$(ip link show dev $if|sed -n "/ether [0-9e-f]\{2\}:.*/p" \ + | sed -e "s/.*ether //;s/ .*//") ;; ipconfig) # fixme: to be checked ipconfig $ip::$gw:$nm:$if:none + MAC="" ;; ifconfig) if [ "$ip" = "0.0.0.0" ]; then @@ -177,6 +180,8 @@ case $ipcfg in ifconfig $if $ip netmask $nm broadcast $bc fi [ "$gw" != "0.0.0.0" ] && route add default gw $gw + MAC=$(ifconfig $if|sed -n "/HWaddr [0-9A-F]\{2\}:.*/p" \ + | sed -e "s/.*HWaddr //;y/ABCDEF/abcdef/") ;; none) error "$error_iptool" @@ -265,8 +270,8 @@ case $dhcp in dhclient) mkdhclconf $vci ln -s /bin/dhcpmkconfig /bin/dhclient-script - dhclient -q -cf /etc/dhclient.conf -lf /var/lib/dhcp/dhclient.leases eth0 \ - 2>&1 >/dev/null || error "$error_dhclient" + dhclient -cf /etc/dhclient.conf -lf /var/lib/dhcp/dhclient.leases \ + -q eth0 2>&1 >/dev/null || error "$error_dhclient" ;; dhcpcd) [ -n $vci ] && vci="-i $vci" @@ -305,16 +310,23 @@ echo "dhcp finished" > /tmp/dhcp-done tftpget () { # $1 is type of tftp command, $2 is config file name to get, $3 IP of # server to get file from +local dst=/tmp/$(basename $2) case "$1" in - atftp) - atftp -g -r $2 $3 + */atftp) + atftp -g -r $2 -l $dst $3 2> /dev/null ;; - tftp) - echo "get $2" | tftp $3 + */tftp) + # distinguish between busybox tftp and standalone (in.tftp) client + if [ -x /bin/busybox ] ; then + tftp -g -r $2 -l $dst $3 2> /dev/null + else + echo "get $2 $dst" | tftp $3 2> /dev/null + fi ;; esac } fileget () { +# get type of tftp available for tftp in /bin/atftp /bin/tftp ; do test -x $tftp && break done @@ -324,17 +336,23 @@ if [ -n "$FILESRC" ] ; then tftpserver=${FILESRC%:*} tftpget $tftp $cfgfile $tftpserver else - cfgfile="/tftpboot/dxs-config" - # ensure that a / is at the end of path to config file - cfgfile=$cfgfile"/" - tftpserver=$serverip - # try to get configuration files successively; start with first part - # of the servers IP, add second part ... - set `IFS="."; echo $serverip` - for i in $1 $2 $3 $4 ; do - cfgfile=$cfgfile$i - tftpget $tftp $cfgfile $tftpserver - cfgfile=$cfgfile"." + cfgdir="/tftpboot/client-config/" + local tftpserver=$serverip + # try to get configuration files successively; start with first most + # generic file (global default), then global client, then distro default + # last distro client ... + echo -e "\n## Configuration via fileget: Hierarchy is first most \ +generic file\n# (global default), then global client, then distro default \ +and as last\n# distro/client" >> /tmp/confviafile + mac=$(echo $MAC|sed "s/:/-/g") + for cfgfile in $cfgdir/default $cfgdir/01-$mac \ + $cfgdir/$DISTRO/default $cfgdir/$DISTRO/01-$mac ; do + echo "# -> $cfgfile" >> /tmp/confviafile + if tftpget $tftp $cfgfile $tftpserver ; then + cat /tmp/$(basename $cfgfile) >> /tmp/confviafile + else + echo -e "# ... this file does not exist on server." >> /tmp/confviafile + fi done fi echo "tftp finished" > /tmp/file-done diff --git a/initrd/initrd-stuff/init b/initrd/initrd-stuff/init index 06be1eba..44c3fe27 100755 --- a/initrd/initrd-stuff/init +++ b/initrd/initrd-stuff/init @@ -2,12 +2,12 @@ # Description: main script for new type of initial ramdisk for # linux diskless clients version 4 # -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 05-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 09-07-2006 # # Copyright: (c) 2006 - RZ Universitaet Freiburg # (c) 2006 - odlx.org project # -# Version: 0.2.5a +# Version: 0.2.6a # functions common for all distros, messages contains all error and info # output @@ -216,15 +216,15 @@ if [ -n "$IPINFO" ] ; then val=${val#*:} ; i=$(expr $i - 1); done; echo $val|sed "s/:.*//"; } - IP=$(getip 1) - SERVER=$(getip 2) - GW=$(getip 3) - NM=$(getip 4) - echo -e "# ip configuration written by $0 script\nclientip=$IP\n\ -sub_netmask=$NM\ngateway=$GW\nserverip=$SERVER" \ + clientip=$(getip 1) + serverip=$(getip 2) + gateway=$(getip 3) + subnet_mask=$(getip 4) + echo -e "# ip configuration written by $0 script\nclientip=$clientip\n\ +subnet_mask=$sub_netmask\ngateway=$gateway\nserverip=$serverip" \ >>/etc/machine-setup # set static ip address via function ipsetup - ipsetup $IP $NM $GW 255.255.255.255 eth0 + ipsetup $clientip $subnet_mask $gateway 255.255.255.255 eth0 else noipyet="yes" fi |