From 2c8289173525442e353a713795b44d55368fbc8f Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Sun, 26 Mar 2006 23:22:18 +0000 Subject: fixed ugly bug with ldd library detection, fixed bug for dhcpcd use, started to integrate gentoo, minor fixes ... git-svn-id: http://svn.openslx.org/svn/openslx/ld4@129 95ad53e4-c205-0410-b2fa-d234c58c8868 --- initrd/initrd-stuff/bin/dhcpmkconfig | 33 +++++------ initrd/initrd-stuff/bin/hwautocfg | 57 +++++++++++-------- initrd/initrd-stuff/bin/servconfig | 98 +++++++++++++++++++------------- initrd/initrd-stuff/etc/functions | 6 +- initrd/initrd-stuff/etc/machine-setup | 102 ---------------------------------- initrd/initrd-stuff/init | 27 ++++----- 6 files changed, 121 insertions(+), 202 deletions(-) delete mode 100644 initrd/initrd-stuff/etc/machine-setup (limited to 'initrd/initrd-stuff') diff --git a/initrd/initrd-stuff/bin/dhcpmkconfig b/initrd/initrd-stuff/bin/dhcpmkconfig index b7dd3cbd..b6c436a6 100755 --- a/initrd/initrd-stuff/bin/dhcpmkconfig +++ b/initrd/initrd-stuff/bin/dhcpmkconfig @@ -4,39 +4,32 @@ # several dhcp clients. The result is written in unified form # to the /etc/machine-setup file # -# Author(s): Dirk von Suchodoletz , 18-01-2006 -# Blabla -# Blub +# Author(s): Dirk von Suchodoletz , 26-03-2006 # # Copyright: (c) 2006 - RZ Universitaet Freiburg -# functions common for all distros -. /etc/functions - # client variable should be exported via calling function echo -e "\n# ip configuration written by $0" \ >>/etc/machine-setup case $0 in - *dhcpd*) - cat /var/lib/dhcp/dhcpcd-eth0.info | sed -n -e '/^new/p' | sed \ - -e "s,',\",g" \ - -e "s,IPADDR,clientip," -e "s,NETMASK,subnet_mask," \ - -e "s,GATEWAY,gateway," -e "s,BROADCAST,broadcast_address," \ - -e "s,HOSTNAME,host_name," -e "s,DOMAIN,domain_name," \ - -e "s,ROOTPATH,root_path," -e "s,DNS,domain_name_servers," \ - -e "s,NTPSERVERS,ntp_servers," -e "s,DHCPSID,serverip," \ + *dhcpcd*) + 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,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.*,," -e "s,.*TIME=.*,," -e "s,CL.*,," \ - -e "s,INTER.*,," -e "s,DHCPSNAME.*,," \ + -e "s,DHCP..ADDR.*,,;s,.*TIME=.*,,;s,CL.*,,;/^$/d" \ + -e "s,INTER.*,,;s,DHCPSNAME.*,," /var/lib/dhcp/dhcpcd-eth0.info \ >>/etc/machine-setup ;; *dhclient*) set | sed -n -e '/^new/p' | sed \ - -e "s,^new_,," -e "s,fixed_address,clientip," \ - -e "s,routers,gateway," -e "s,dhcp_server_identifier,serverip," \ - -e "s,.*_t[iy][mp]e.*,," -e "s,.*_message_.*,," -e "/^$/d" \ - -e "s,language=,country=," -e "s,ip_address,clientip," \ + -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," \ >>/etc/machine-setup ;; *pump*) diff --git a/initrd/initrd-stuff/bin/hwautocfg b/initrd/initrd-stuff/bin/hwautocfg index bc9ffd11..cfd2c74a 100755 --- a/initrd/initrd-stuff/bin/hwautocfg +++ b/initrd/initrd-stuff/bin/hwautocfg @@ -240,14 +240,6 @@ pci/agp bus needed for acceleration." ; } esac echo -e "EndSection\n" >>$xfc done -# only if X is link itself (normally to /var/X11R6/bin/X) check!! -link=`ls -l /mnt/usr/X11R6/bin/X 2>/dev/null` -if strinstr "/var/X11R6" "$link" ; then - testmkd /mnt/var/X11R6/bin - for i in /usr/X11R6/bin/Xorg /usr/X11R6/bin/XFree86 ; do - [ -e "/mnt/$i" ] && { ln -sf $i /mnt/var/X11R6/bin/X; break; } - done -fi } ####################################################################### @@ -412,12 +404,31 @@ data via dhcp until now ..." nonfatal waitfor /tmp/ldap-done 10000 || error " Did not get any configuration \ data via ldap until now ..." nonfatal . /etc/machine-setup + +# postpone some commands into normal bootup environment +echo -e "\t# entries added by $0: $date" >> /etc/boot.ld +# run localizator and configure keyboard and console fonts +DEFKEYTABLE="de-latin1-nodeadkeys" +localization $country +if [ -z "${KEYTABLE}" ] ; then + msg "Keyboard setup" "No settings found for keyboard, using default of \ +'${DEFKEYTABLE}' defined\nin $0." + KEYTABLE=${DEFKEYTABLE} +fi +echo -e "\tloadkeys -q ${KEYTABLE}" >> /etc/boot.ld + +# run X11 / Xorg configurator +. /etc/sysconfig/xserver >/dev/null 2>&1 || error " The xserver \ +configuration file generated by hwsetup could not\n be found." nonfatal +( displaysetup /etc/xorg.conf; echo "ready" > /tmp/xready ) & + # wait for completion of clients root filesystem in /mnt waitfor /tmp/fscmpl 40000 -# postpone some commands into normal bootup environment -echo -e "\t# entry added by $0: $date" \ - >>/mnt/etc/${D_INITDIR}/boot.ld +# add entries to boot.ld +cat /etc/boot.ld >> /mnt/etc/${D_INITDIR}/boot.ld +[ -n "${CONSOLE_FONT}" ] && consolefont + # get idea of availabe harddisk partitions, put swap partitions into # (/mnt)/etc/fstab and format and mount partitions of type 44 (unknown) for hd in $(cat /tmp/hwsetup.info|sed -n -e '/HD$/,/device:/p'| \ @@ -448,19 +459,17 @@ done # determine if tmp preparation should wait for format/mount or not [ -z "$part44" ] && echo "finished" > /tmp/tmpready -# run localizator and configure keyboard and console fonts -DEFKEYTABLE="de-latin1-nodeadkeys" -localization $country -if [ -z "${KEYTABLE}" ] ; then - msg "Keyboard setup" "No settings found for keyboard, using default of \ -'${DEFKEYTABLE}' defined\nin $0." - KEYTABLE=${DEFKEYTABLE} +# finalize X configuration +# only if X is link itself (normally to /var/X11R6/bin/X) check!! +link=`ls -l /mnt/usr/X11R6/bin/X 2>/dev/null` +if strinstr "/var/X11R6" "$link" ; then + testmkd /mnt/var/X11R6/bin + for i in /usr/X11R6/bin/Xorg /usr/X11R6/bin/XFree86 ; do + [ -e "/mnt/$i" ] && { ln -sf $i /mnt/var/X11R6/bin/X; break; } + done fi -echo -e "\tloadkeys -q ${KEYTABLE}\n" >>/mnt/etc/${D_INITDIR}/boot.ld -[ -n "${CONSOLE_FONT}" ] && consolefont -# run X11 / Xorg configurator -. /etc/sysconfig/xserver >/dev/null 2>&1 || error " The xserver \ -configuration file generated by hwsetup could not\n be found." nonfatal -displaysetup ${D_XF86CONFFILE} +# wait for completion of Xorg configuration +waitfor /tmp/xready 1000 +cp /etc/xorg.conf ${D_XF86CONFFILE} echo "finished" > /tmp/hwcfg diff --git a/initrd/initrd-stuff/bin/servconfig b/initrd/initrd-stuff/bin/servconfig index 2be55ba7..5799e5f7 100755 --- a/initrd/initrd-stuff/bin/servconfig +++ b/initrd/initrd-stuff/bin/servconfig @@ -116,9 +116,28 @@ case ${DISTRO} in done ;; gentoo*) + rm /mnt/etc/*/.critical 2>/dev/null for i in ${D_INITSCRIPTS}; do ln -sf /etc${D_INITDIR}/$i /mnt/etc/${D_INITBOOTD}/$i + echo $i >> /mnt/etc/${D_INITBOOTD}/.critical + echo $i >> /mnt/etc/default/.critical done + +# ( for i in /mnt/etc/init.d/*; do +# strinstr ".sh" "$i" && continue +# script=${i#/mnt/etc/init.d/*} +# if ! strinstr "$script " "${D_INITSCRIPTS} " ; then +# for j in /mnt/etc/init.d/*; do +# strinstr ".sh" "$j" && continue +# link=${j#/mnt/etc/init.d/*} +# if ! strinstr "$script" "$link" ; then +# sed "/depend/,/}/s/$script //;/depend/,/}/s/$script$//" \ +# /mnt/etc/init.d/$link > /tmp/rlvscript +# cp /tmp/rlvscript /mnt/etc/init.d/$link +# fi +# done +# fi +# done ) & ;; esac @@ -204,7 +223,7 @@ if [ "x$vmware" != "x" ] || [ "x$vmware" != "xno" ] ; then ${imgsrv} /mnt/var/lib/vmware & fi # generate a runlevel script - d_mkrlscript init vmware-prep 'Starting preparation of vmware environment' + d_mkrlscript init vmware-prep "Starting preparation of vmware environment" sed "s,^#.*,,;/^$/d;s,^,\t," /etc/vmware-prep >> \ /mnt/etc/${D_INITDIR}/vmware-prep d_mkrlscript close vmware-prep "" @@ -216,6 +235,39 @@ if [ "x$vmware" != "x" ] || [ "x$vmware" != "xno" ] ; then export vmsessions=/var/lib/vmware/vmsessions fi +####################################################################### +# NIS +# setup nis configuration if needed +if [ "x$nis_domain" != "x" ] && [ "x$nis_servers" != "x" ] ; then + echo $nis_domain >/mnt/etc/defaultdomain + echo -e "# /etc/yp.conf - file generated by $0:\n#\t\ +$date\n\nypserver "$nis_servers >/mnt/etc/yp.conf + # should be last in passwd file + strinfile "+::::::" /mnt/etc/passwd||echo "+::::::" >>/mnt/etc/passwd +fi + +####################################################################### +# name service caching daemon if networked user database +config_nscd + +####################################################################### +# preparation of /tmp directory (partition 44, nfs scratch, ramdisk) +waitfor /tmp/tmpready 10000 +# create some directories and correct permissions +tmpisdisk=`sed -n '/\/tmp/p' /mnt/etc/fstab` +# if there is no local disk partition for /tmp then try to mount a rw +# NFS scratch space (if defined in $scratch) and prepared on server +if [ -n "$scratch" -a -z "$tmpisdisk" ] ; then + mkdir -p /tmp/scratch >/dev/null 2>&1 + mount -t nfs -o rw,nolock,intr,nodev,soft,timeo=2,nosuid ${scratch} \ + /tmp/scratch >/dev/null 2>&1 && { + mkdir -p /tmp/scratch/${clientip} >/dev/null 2>&1 + umount /tmp/scratch + mount -t nfs -o rw,nolock,intr,nodev,soft,timeo=2,nosuid \ + ${scratch}/${clientip} /mnt/tmp >/dev/null 2>&1; } +fi +chmod 1777 /mnt/tmp + ####################################################################### # X11/GUI stuff if [ "x$start_x" != "xno" ] ; then @@ -225,7 +277,11 @@ if [ "x$start_x" != "xno" ] ; then /etc/X11/xdm \ /etc/X11/sessions \ /var/X11R6/bin \ - /var/run/xdmctl; do testmkd /mnt/$i; done + /var/run/xdmctl \ + /tmp/.ICE-unix \ + /tmp/.X11-unix ; do testmkd /mnt/$i; done + chmod a+rwxt /mnt/tmp/.ICE-unix + chmod a+rwxt /mnt/tmp/.X11-unix echo "" > /mnt/etc/X11/xdm/Xservers # define additional sessions offered to the user (via dhcp/ldap config) # descsession -> deprecated by new vmware integration concept @@ -333,43 +389,5 @@ DisplayManager.*.reset:\t\t/etc/X11/xdm/Xreset" >/mnt/etc/X11/xdm/xdm-config esac fi -####################################################################### -# NIS -# setup nis configuration if needed -if [ "x$nis_domain" != "x" ] && [ "x$nis_servers" != "x" ] ; then - echo $nis_domain >/mnt/etc/defaultdomain - echo -e "# /etc/yp.conf - file generated by $0:\n\ -#\t$date\n\nypserver "$nis_servers >/mnt/etc/yp.conf - # should be last in passwd file - strinfile "+::::::" /mnt/etc/passwd||echo "+::::::" >>/mnt/etc/passwd -fi - -####################################################################### -# name service caching daemon if networked user database -config_nscd - -####################################################################### -# preparation of /tmp directory (partition 44, nfs scratch, ramdisk) -waitfor /tmp/tmpready 10000 -# create some directories and correct permissions -tmpisdisk=`sed -n '/\/tmp/p' /mnt/etc/fstab` -# if there is no local disk partition for /tmp then try to mount a rw -# NFS scratch space (if defined in $scratch) and prepared on server -if [ -n "$scratch" -a -z "$tmpisdisk" ] ; then - mkdir -p /tmp/scratch >/dev/null 2>&1 - mount -t nfs -o rw,nolock,intr,nodev,soft,timeo=2,nosuid ${scratch} \ - /tmp/scratch >/dev/null 2>&1 && { - mkdir -p /tmp/scratch/${clientip} >/dev/null 2>&1 - umount /tmp/scratch - mount -t nfs -o rw,nolock,intr,nodev,soft,timeo=2,nosuid \ - ${scratch}/${clientip} /mnt/tmp >/dev/null 2>&1; } -fi -chmod 1777 /mnt/tmp -for i in \ - /tmp/.ICE-unix \ - /tmp/.X11-unix; do testmkd /mnt/$i; done -chmod a+rwxt /mnt/tmp/.ICE-unix -chmod a+rwxt /mnt/tmp/.X11-unix - # servconfig finished successfully echo "finished" > /tmp/svcfg diff --git a/initrd/initrd-stuff/etc/functions b/initrd/initrd-stuff/etc/functions index 65a811ca..0dc48254 100644 --- a/initrd/initrd-stuff/etc/functions +++ b/initrd/initrd-stuff/etc/functions @@ -237,8 +237,8 @@ case $dhcp in error " Fatal error occured while trying to run dhclient.\n$commonerr" ;; dhcpcd) - ln -s /bin/dhcpmkconfig /bin/dhcpd.exe - dhcpcd -L /var/lib/dhcp -c /bin/dhcpd.exe -T -t 30 eth0 2>&1 >/dev/null || \ + ln -s /bin/dhcpmkconfig /bin/dhcpcd.exe + dhcpcd -L /var/lib/dhcp -c /bin/dhcpcd.exe -T -t 30 eth0 2>&1 >/dev/null || \ error " Fatal error occured while trying to run dhcpcd.\n$commonerr" ;; pump) @@ -390,7 +390,7 @@ sed -n -e '/nobody/p' /mnt/etc/passwd >> /tmp/newpasswd cp /tmp/newpasswd /mnt/etc/passwd # create the shadow from passwd file echo -e "root:"$root_pw":12958:0:10000::::" > /mnt/etc/shadow -sed 's/:.*/:!:13078:0:99999:7:::/' /tmp/newpasswd >> /mnt/etc/shadow +sed 's/:.*/:!:13078:0:99999:7:::/;/^root.*/d' /tmp/newpasswd >> /mnt/etc/shadow } ####################################################################### diff --git a/initrd/initrd-stuff/etc/machine-setup b/initrd/initrd-stuff/etc/machine-setup deleted file mode 100644 index 24e754c5..00000000 --- a/initrd/initrd-stuff/etc/machine-setup +++ /dev/null @@ -1,102 +0,0 @@ -# machine-setup -# Description: universal (distro independent) configuration file for -# linux diskless clients v4.0. It defines default values -# for several configuration variables. These settings might -# be overwritten through various processes in initial ramdisk. -# New settings are simply appended, so that they might -# overwrite previously defined variables -# -# Author(s): Dirk von Suchodoletz , 09-03-2006 -# Blabla -# Blub -# -# Copyright: (c) 2003 - 2006 - RZ Universitaet Freiburg -# -## format variable="static_value" or variable="$serverip:123" ## -## it is possible to use the variables $serverip (the IP of the ## -## providing DHCP server - not neccessarily NFS server), $clientip ## -## (the IP of the client itself) and $host_name ## -# -# -# password of system administrator (root) as crypt -> 'dxs-root' -root_pw='$2a$10$MoEYhIPZGCtR62R8UvBl3emNn2qMOuQpLQpfmNnhya4bGLhyF0pbu' - -## name service configuration defaults -# -# host and domain name -host_name="dxs" -domain_name="test.ldc" - -# define country for all localization stuff - see functions how country -# is translated to LANGUAGE, COUNTRY, LANG, KEYTABLE, XKEYBOARD, -# KDEKEYBOARD, CHARSET, KDEKEYBOARDS, TZ and CONSOLEFONT -country="de" - -## set some default variables -# -# enable setup of TeX environment -tex_enable="no" - -## services to start (yes) or configure (may) or disable (no) -# -# network time protocol daemon ("yes" for normal daemon operation, -# "initial" just for setting during startup with ntpdate) -start_ntp="initial" -# set timezone if not to be derived from language setting -# timezone="Europe/Berlin" - -# start sshd (hostkeys should be pregenerated by install script) -start_sshd="yes" - -# start rwhod service (lan wide login and uptime list) -start_rwhod="no" - -# start log server (remote log servers could be passed via dhcp option) -start_syslog="yes" - -# start cron service -start_cron="no" - -# start at daemon -start_atd="no" - -# simple network management protocol for system monitoring -start_snmp="no" - -# dbus, resource manager , hal (hardware abstraction layer) interoperate -# tighly. There might be little different solutions within each distro -start_dreshal="yes" - -# start alsa sound system -start_alsasound="yes" - -# start ssh server -start_sshd="yes" - -# AFS network filesystem -start_afs="no" -this_cell="uni-freiburg.de" -cell_server="132.230.6.237 132.230.6.236 132.230.6.235" - -# smb protocol service (provide windows file service) -start_samba="may" -netbios_workgroup="dxs-network" - -# automounter home (/local_dir - top level directories only) and source -# (server:/path) -automnt_dir="/home" -automnt_src="$serverip:/home" - -# scratch space on server -scratch="$serverip:/dxs/tmp" - -# configure and start vmware services -vmware="no" -imgsrv="$serverip:/dxs/vmware" - -# kind of X11 display manager to run -start_xdmcp="xdm" - -# should Xorg/XFree server be started or some special windowmanager be run -# in kiosk mode e.g. start_x="kde" -start_x="yes" diff --git a/initrd/initrd-stuff/init b/initrd/initrd-stuff/init index 7ac6c087..f0882aea 100755 --- a/initrd/initrd-stuff/init +++ b/initrd/initrd-stuff/init @@ -164,6 +164,7 @@ if [ "${DEBUGLEVEL}" -gt 0 ] ; then # if LOGFILE should be used within initial ramdisk add '/mnt' in front # of the variable LOGFILE="/var/log/dxs-boot.log" + echo "1 4 1 7" >/proc/sys/kernel/printk [ "${DEBUGLEVEL}" -eq 2 ] && MODPRV="-v" [ "${DEBUGLEVEL}" -gt 2 ] && { set -x @@ -223,17 +224,18 @@ if [ -n "${NBD}" ] ; then nbdhost=${NBDOPT%:*} nbdopt=${NBDOPT#*:} nbdport=${nbdopt%,*} - nbdfs=${nbdopt#*,} - echo "Diskless client using ${NBD} on $nbdhost:$nbdport with $nbdfs" + nbdfs=${nbdopt#$nbdport*} if [ -z "$nbdfs" ]; then RFST=ext2; else - RFST=$nbdfs; - # fixme: check for fs in /proc/filesystems before trying to load the module - modprobe ${MODPRV} ${RFST} || error " Failed to load the requested \ -filesystem module for the client root\n filesystem ontop of the (D)NBD." \ - nonfatal + RFST=${nbdfs#*,}; fi + echo "Diskless client using ${NBD} on $nbdhost:$nbdport with $RFST" + # fixme: check for fs in /proc/filesystems before trying to load the module + modprobe ${MODPRV} ${RFST} || error " Failed to load the requested \ +filesystem module for the client root\n filesystem ontop of the (D)NBD." \ + nonfatal + errmsg=" For some reason the network block device /dev/${NBD}0 never \ appeared.\n You might want to check udev or your list of static device \ files." @@ -259,11 +261,11 @@ the network block device client. Unable to mount root\n filesystem." while ! dnbd-client -b $nbdhost -d /dev/dnbd0 $clientopt ; do usleep 10 done - echo $? + #echo $? RDEV=/dev/dnbd0 - usleep 20 - ;; + ;; esac + usleep 20 mount -n -t $RFST -o ro $RDEV /mnt fi # if no type of root filesystem is passed via kernel command line try @@ -361,14 +363,13 @@ else mount -n --bind ${RWDIR}/var /mnt/var # get the "covered" mounts back into filesystem structure for i in ${LIST}; do - #rm -rf /* >/dev/null 2>&1 mount -n --move /root/$i /mnt/$i #>>$LOGFILE 2>&1 done - rm -rf /root/* >/dev/null 2>&1 + #rm -rf /root/* >/dev/null 2>&1 # run some specific stuff !? fi # script for stuff to execute during early bootup -d_mkrlscript init boot.ld "Running post configuration required by init" +d_mkrlscript init boot.ld "Running configuration postponed from InitRD" echo "fs complete" >/tmp/fscmpl # write debug file information after filesystem setup completed -- cgit v1.2.3-55-g7522