diff options
author | Dirk von Suchodoletz | 2006-07-24 00:24:23 +0200 |
---|---|---|
committer | Dirk von Suchodoletz | 2006-07-24 00:24:23 +0200 |
commit | fc00da9d4e627ee0022337e41df745cb40b9479c (patch) | |
tree | e399a6a6c0f967847534f4ddab9ca3ecc14b95dc /initrd | |
parent | Check-in of basic configuration database design: (diff) | |
download | core-fc00da9d4e627ee0022337e41df745cb40b9479c.tar.gz core-fc00da9d4e627ee0022337e41df745cb40b9479c.tar.xz core-fc00da9d4e627ee0022337e41df745cb40b9479c.zip |
Added function for URI interpretation, enabling URI notation for several
sources (fileget, fileservice, ...), moved local configurable hardware
configuration (pcitable.local, Cards.local) to central config directory
on server (added to hwdata files by mkdxsinitrd) ...
git-svn-id: http://svn.openslx.org/svn/openslx/ld4@285 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'initrd')
-rwxr-xr-x | initrd/initrd-stuff/bin/hwautocfg | 8 | ||||
-rwxr-xr-x | initrd/initrd-stuff/bin/servconfig | 35 | ||||
-rw-r--r-- | initrd/initrd-stuff/etc/functions | 87 | ||||
-rwxr-xr-x | initrd/initrd-stuff/init | 27 | ||||
-rw-r--r-- | initrd/initrd-stuff/usr/share/hwdata/Cards.local | 16 | ||||
-rw-r--r-- | initrd/initrd-stuff/usr/share/hwdata/pcitable.local | 15 | ||||
-rwxr-xr-x | initrd/mkdxsinitrd | 12 |
7 files changed, 118 insertions, 82 deletions
diff --git a/initrd/initrd-stuff/bin/hwautocfg b/initrd/initrd-stuff/bin/hwautocfg index 827611c5..866ea0d5 100755 --- a/initrd/initrd-stuff/bin/hwautocfg +++ b/initrd/initrd-stuff/bin/hwautocfg @@ -4,7 +4,7 @@ # script for linux diskless clients, using hwconfig from # knoppix as base tool # -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 10-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 15-07-2006 # Felix Endres # # Copyright: (c) 2003 - 2006 - RZ Universitaet Freiburg @@ -428,9 +428,9 @@ for hd in $(cat /tmp/hwsetup.info|sed -n -e '/HD$/,/device:/p'| \ # we use special non assigned partition type for harddisk scratch space for hdpartnr in $(cat /tmp/hd_part | \ sed -n -e "/ 44 /p"|sed -e "s/[[:space:]].*//") ; do - # ugly message from ext2 mount :-( - ( mkfs.ext2 -q $hdpartnr; mount -n $hdpartnr /mnt/tmp; \ - echo "$hdpartnr" > /tmp/tmpready ) & + # ext2fs_check_if_mount message supressed + ( mkfs.ext2 -Fq $hdpartnr 2>/dev/null; mount -n -o nocheck,noexec \ + $hdpartnr /mnt/tmp 2>/dev/null; echo "$hdpartnr" > /tmp/tmpready ) & echo -e "$hdpartnr\t/tmp\t\text2\t\tdefaults\t 0 0" >> /tmp/fstab part44=yes break diff --git a/initrd/initrd-stuff/bin/servconfig b/initrd/initrd-stuff/bin/servconfig index b6d5aedb..0239e401 100755 --- a/initrd/initrd-stuff/bin/servconfig +++ b/initrd/initrd-stuff/bin/servconfig @@ -4,7 +4,7 @@ # for linux diskless clients (executed within initial # ramdisk) # -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 09-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 23-07-2006 # Michael Janczyk, 31-05-2006 # Lars Mueller, 23-06-2006 # Oliver Tappe, 23-06-2006 @@ -83,9 +83,19 @@ if [ "x$vmware" != "x" ] && [ "x$vmware" != "xno" ] ; then if [ -d /mnt/usr/share/vmware ] ; then ln -sf /usr/share/vmware /mnt/var/lib/vmware elif [ -n "${imgsrv}" ] ; then - # # more general mount script should be used here!? + # get type, server, path of VMware image export + vmimgsprot=$(uri_token $imgsrv prot) + vmimgsserv=$(uri_token $imgsrv server) + vmimgspath="/$(uri_token $imgsrv path)" + case "$vmimgsprot" in + *nbd) + ;; + *) + # # more general mount script should be used here!? nfsmnt ${imgsrv} /mnt/var/lib/vmware || { error "$scfg_nfs" nonfatal; noimg=yes; } + ;; + esac fi fi @@ -324,15 +334,24 @@ 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 +# scratch space (if defined in $scratch) and prepared on server if [ -n "$scratch" -a -z "$tmpisdisk" ] ; then + scrproto=$(uri_token $FILESRC prot) + scrpath=$(uri_token $FILESRC path) mkdir -p /tmp/scratch >/dev/null 2>&1 - mount -t nfs -o rw,nolock,intr,nodev,soft,timeo=2,nosuid ${scratch} \ + case "$scrproto" in + nbd) + # exports have to be per client!! + ;; + *) + 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; } + 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; } + ;; + esac fi chmod 1777 /mnt/tmp diff --git a/initrd/initrd-stuff/etc/functions b/initrd/initrd-stuff/etc/functions index e354c2ce..b05291b9 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>, 09-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 24-07-2006 # Felix Endres, 30-04-2006 # Tobias Maier # # Copyright: (c) 2006 - RZ Universitaet Freiburg # -# Version: 0.5.0b +# Version: 0.5.1a ####################################################################### # set of empty dummy functions (loaded before real functions in the @@ -112,7 +112,48 @@ return 0 ldcfg () { [ -z "${NOLDSC}" ] && echo "$init_ldcfg" && ldconfig /tmp/ld.so.cache & } - +####################################################################### +# URI interpreter $1 variable to interprete, $2 type of token to return +# prot: tftp, http, nbd, ... server: IP or FQDN +uri_token () { +local var=$1 +# first check if URI starts with prot:// - URI scheme +if strinstr "://" "$1" ; then + prot=${var%://*} + rest=${var#*://} +else + rest="$var" + prot="" +fi +# get the server IP or name and port - URI authority +# you get the path or other token without leading "/" - add it later if +# needed +if strinstr ":" "$rest" ; then + server="${rest%:*}" + rest="${rest#*:}" + path="${rest#*/}" + port="${rest%/$path}" +else + server="${rest%/*}" + rest="${rest#*/}" + path="${rest#*/}" + port="" +fi +# get path and query components - URI path, query +query="" +if strinstr "\?" "$rest" ; then + path="${path%\?*}" + query="${rest#*\?}" +fi +# return the requested token +case "$2" in + prot) echo "$prot" ;; + server) echo "$server" ;; + path) echo "$path" ;; + port) echo "$port" ;; + query) echo "$query" ;; +esac +} ####################################################################### # load a certain module - name of module with path in argument one, the # error message in second argument @@ -308,32 +349,34 @@ echo "dhcp finished" > /tmp/dhcp-done # kernel command line) # tftpget is helper function for fileget 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 +# $1 is config file name to get, $2 IP of server to get file from +for tftp in /bin/atftp /bin/tftp ; do + test -x $tftp && break +done +echo -e "tftp\t69/tcp\ntftp\t69/udp" > /etc/services +local dst=/tmp/$(basename $1) +case "$tftp" in */atftp) - atftp -g -r $2 -l $dst $3 2> /dev/null + atftp -g -r $1 -l $dst $2 2> /dev/null ;; */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 + tftp -g -r $1 -l $dst $2 2> /dev/null else - echo "get $2 $dst" | tftp $3 2> /dev/null + echo "get $1 $dst" | tftp $2 2> /dev/null fi ;; esac } fileget () { -# get type of tftp available -for tftp in /bin/atftp /bin/tftp ; do - test -x $tftp && break -done -echo -e "tftp\t69/tcp\ntftp\t69/udp" > /etc/services +# get type of tftp available, alternatively use wget for ftp or http +# (fixme: rewrite of fileget needed!!) +# analyze file soure (URI) in $FILESRC if [ -n "$FILESRC" ] ; then - cfgfile=${FILESRC#*:} - tftpserver=${FILESRC%:*} + srvproto=$(uri_token $FILESRC prot) + cfgfile="/$(uri_token $FILESRC path)" + tftpserver=$(uri_token $FILESRC server) tftpget $tftp $cfgfile $tftpserver else cfgdir="/tftpboot/client-config/" @@ -348,14 +391,14 @@ and as last\n# distro/client" >> /tmp/confviafile 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 + if tftpget $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 +echo "fileget via $srvproto finished" > /tmp/file-done } ####################################################################### @@ -767,9 +810,9 @@ case "${XMODULE}" in radeon) # check ${XDESC}/ hwsetup.info device string in Cards file and then # for needed components - test -f /mnt/lib/modules/${KERNEL}/kernel/drivers/char/drm/fglrx.ko && \ - test -f /mnt/usr/X11R6/lib/modules/drivers/fglrx_drv.o && \ - XMODULE=fglrx + test -f /mnt/lib/modules/${KERNEL}/kernel/drivers/char/drm/fglrx.ko \ + && test -f /mnt/usr/X11R6/lib/modules/drivers/fglrx_drv.o && \ + XMODULE=fglrx # there seems no problem, if no TV is connected TVOUT='\tOption\t\t"TVFormat" "PAL-B"\n \tOption\t\t"DesktopSetup" "horizontal"' diff --git a/initrd/initrd-stuff/init b/initrd/initrd-stuff/init index 2cbc49cd..2686cfde 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>, 09-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 24-07-2006 # # Copyright: (c) 2006 - RZ Universitaet Freiburg # (c) 2006 - odlx.org project # -# Version: 0.2.6a +# Version: 0.2.6d # functions common for all distros, messages contains all error and info # output @@ -103,7 +103,7 @@ in $0\ncountry=\"${COUNTRY}\"" >> /etc/machine-setup # if (external, via tftp) configuration file retrieval should # be triggered, if no source is given try dhcp server and # predefined standard path (~/tftpboot/client-conf/default, - # client-conf/<name-of-export>/default, ...) + # client-conf/<name-of-export>/default, ...) file) FILE="yes" rm /tmp/file-done @@ -248,19 +248,14 @@ fi if [ -n "${NBD}" ] ; then # load block device driver if needed modprobe ${MODPRV} ${NBD} || error "$init_errnbd" - # get settings for nbd-client - nbdhost=${NBDOPT%:*} - nbdopt=${NBDOPT#*:} - nbdport=${nbdopt%,*} - nbdfs=${nbdopt#$nbdport*} - if [ -z "$nbdfs" ]; then - RFST=ext2; - else - RFST=${nbdfs#*,}; - fi - echo "Diskless client using ${NBD} on $nbdhost:$nbdport with $RFST" + # get settings for nbd-client, filesystem equals to path in URI notation + nbdhost=$(uri_token $NBDOPT server) + nbdport=$(uri_token $NBDOPT port) + nbdrfst=$(uri_token $NBDOPT path) + [ -z "$nbdrfst" ] && nbdrfst=ext2 + echo "Diskless client using ${NBD} on $nbdhost:$nbdport with $nbdrfst" # fixme: check for fs in /proc/filesystems before trying to load the module - modprobe ${MODPRV} ${RFST} || error "$init_errnbd" nonfatal + modprobe ${MODPRV} ${nbdrfst} || error "$init_errnbd" nonfatal case "${NBD}" in # network block device present in standard kernel @@ -319,7 +314,7 @@ if [ -n "${NBD}" ] ; then # finally mount the block device for i in 5 40 60 ; do usleep $i - mount -n -t $RFST -o $RWRO $RDEV /mnt 2>/dev/null && break + mount -n -t $nbdrfst -o $RWRO $RDEV /mnt 2>/dev/null && break done fi diff --git a/initrd/initrd-stuff/usr/share/hwdata/Cards.local b/initrd/initrd-stuff/usr/share/hwdata/Cards.local deleted file mode 100644 index 82de1257..00000000 --- a/initrd/initrd-stuff/usr/share/hwdata/Cards.local +++ /dev/null @@ -1,16 +0,0 @@ -#~/usr/share/hwdata/Cards.local -# -# Description: local changes to the Cards file. All additions should be -# documented here, so that they are not lost ... -# -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 08-07-2006 -# -# Copyright: (c) 2006 - RZ Universitaet Freiburg -# (c) 2006 - odlx.org project -# -# Version: 0.0.1a - -NAME Intel 945 -CHIPSET Intel 945 -DRIVER i810 -NOCLOCKPROBE diff --git a/initrd/initrd-stuff/usr/share/hwdata/pcitable.local b/initrd/initrd-stuff/usr/share/hwdata/pcitable.local deleted file mode 100644 index a5307580..00000000 --- a/initrd/initrd-stuff/usr/share/hwdata/pcitable.local +++ /dev/null @@ -1,15 +0,0 @@ -#~/usr/share/hwdata/pcitable.local -# -# Description: local changes to the pcitables file. All additions should be -# documented here, so that they are not lost ... -# this file seems to be part of RedHat (and others) hardware -# detection tool suite -# -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 08-07-2006 -# -# Copyright: (c) 2006 - RZ Universitaet Freiburg -# (c) 2006 - odlx.org project -# -# Version: 0.0.1a - -0x8086 0x2772 "Card:Intel 945" diff --git a/initrd/mkdxsinitrd b/initrd/mkdxsinitrd index 05325f13..dd5d1045 100755 --- a/initrd/mkdxsinitrd +++ b/initrd/mkdxsinitrd @@ -3,7 +3,7 @@ # Description: universal (distro independent) generator for initial # ramdisks for linux diskless clients # -# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 08-07-2006 +# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 23-07-2006 # Nico Dietrich # Felix Endres # @@ -663,6 +663,16 @@ if [ -f /etc/dxs/client.cfg/boot.local.default ] ; then cp /etc/dxs/client.cfg/boot.local.default ${INSTDIR}/etc/boot.local fi +# custom hardware configuration files pcitable.local and Cards.local +if [ -f /etc/dxs/client.cfg/pcitable.local ] ; then + cat /etc/dxs/client.cfg/pcitable.local >> \ + ${INSTDIR}/usr/share/hwdata/pcitable +fi +if [ -f /etc/dxs/client.cfg/Cards.local ] ; then + cat /etc/dxs/client.cfg/Cards.local >> \ + ${INSTDIR}/usr/share/hwdata/Cards +fi + # finally copy user-supplied preinit and postinit files # fixme: where are these files coming from?? #for i in vendor_preinit vendor_postinit ; do |