summaryrefslogtreecommitdiffstats
path: root/initrd
diff options
context:
space:
mode:
authorDirk von Suchodoletz2006-08-16 00:58:42 +0200
committerDirk von Suchodoletz2006-08-16 00:58:42 +0200
commit91635afc52c96467e0e994d03284ab65db40526f (patch)
treea650865536bb684d9478b771d6272dccd9e93876 /initrd
parentSimple install mechanism for directory structure setup (make install) (diff)
downloadcore-91635afc52c96467e0e994d03284ab65db40526f.tar.gz
core-91635afc52c96467e0e994d03284ab65db40526f.tar.xz
core-91635afc52c96467e0e994d03284ab65db40526f.zip
Extended configuration mechanism (get tgz files instead of simple
machine-setup for advanced config), tested with normal toolset and busybox, small bugfixes like: fixed duplicate entries to machine-setup, small ash-sh related bug, ... git-svn-id: http://svn.openslx.org/svn/openslx/trunk@300 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'initrd')
-rwxr-xr-xinitrd/initrd-stuff/bin/servconfig15
-rw-r--r--initrd/initrd-stuff/etc/functions34
-rwxr-xr-xinitrd/initrd-stuff/init15
-rwxr-xr-xinitrd/mkdxsinitrd40
4 files changed, 61 insertions, 43 deletions
diff --git a/initrd/initrd-stuff/bin/servconfig b/initrd/initrd-stuff/bin/servconfig
index 5d266f97..a4577a97 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>, 15-08-2006
+# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 16-08-2006
# Michael Janczyk, 31-05-2006
# Lars Mueller <lm@opendiskless.org>, 23-06-2006
# Oliver Tappe <ot@opendiskless.org>, 23-06-2006
@@ -12,7 +12,7 @@
# Copyright: (c) 2006 - RZ Universitaet Freiburg
# (c) 2006 - opendiskless.org project
#
-# Version: 0.1.2a
+# Version: 0.1.2b
# check for configuration files to source
@@ -65,12 +65,11 @@ echo "
cfgcomplete
. /etc/machine-setup
-# hack for replacing variables ($serverip, $clientip, $host_name) in
-# machine-setup
-sed -e "s/\$serverip/$serverip/;s/\$clientip/$clientip/" \
- /etc/machine-setup > /etc/machine-setup.new
-cp /etc/machine-setup.new /etc/machine-setup
-. /etc/machine-setup
+# copy additional configuration and var files and directories
+# admins can place there files in /var/lib/opendiskless/config/...
+# to be packed during stage2 into (/srv/dxs)/tftpboot/client-config...)
+# ... in the near future ...
+cp -a /rootfs/* /mnt 2>/dev/null
#######################################################################
# vmware stuff first part: two scenarios
diff --git a/initrd/initrd-stuff/etc/functions b/initrd/initrd-stuff/etc/functions
index 7cf5193e..f2dfe06f 100644
--- a/initrd/initrd-stuff/etc/functions
+++ b/initrd/initrd-stuff/etc/functions
@@ -2,7 +2,7 @@
# linux diskless clients (included by init, hwautocfg,
# servconfig, ... within initial ramdisk)
#
-# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 10-08-2006
+# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 15-08-2006
# Felix Endres, 30-04-2006
# Tobias Maier
#
@@ -348,13 +348,14 @@ echo "dhcp finished" > /tmp/dhcp-done
# from a predefined server or given source (file=tftp-server:/path via
# kernel command line)
# tftpget is helper function for fileget
-tftpget () {
+tftpgetunpack () {
# $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)
+# tftp get part
case "$tftp" in
*/atftp)
atftp -g -r $1 -l $dst $2 2> /dev/null
@@ -368,6 +369,14 @@ case "$tftp" in
fi
;;
esac
+# unpack part (only gzip is supported)
+if [ -s $dst ] ; then
+ tar -xpzf $dst
+ rm $dst
+ return 0
+else
+ return 1
+fi
}
fileget () {
# get type of tftp available, alternatively use wget for ftp or http
@@ -377,7 +386,7 @@ if [ -n "$FILESRC" ] ; then
srvproto=$(uri_token $FILESRC prot)
cfgfile="/$(uri_token $FILESRC path)"
tftpserver=$(uri_token $FILESRC server)
- tftpget $tftp $cfgfile $tftpserver
+ tftpgetunpack $tftp $cfgfile $tftpserver
else
cfgdir="/tftpboot/client-config/"
local tftpserver=$serverip
@@ -386,14 +395,14 @@ else
echo -e "\n## Configuration via fileget: Hierarchy is distro client \
and as last\n# distro/default" >> /tmp/confviafile
mac=$(echo $MAC|sed "s/:/-/g")
- for cfgfile in $cfgdir/$DISTRO/01-$mac $cfgdir/$DISTRO/default ; do
- if tftpget $cfgfile $tftpserver ; then
- : # unpack the tgz and distribute files
- fi
+ for cfgfile in $cfgdir/$DISTRO/01-$mac.tgz $cfgdir/$DISTRO/default.tgz \
+ $cfgdir/01-$mac.tgz $cfgdir/default.tgz ; do
+ tftpgetunpack $cfgfile $tftpserver && break
done
fi
#echo "# -> $cfgfile" >> /tmp/confviafile
-#cat /tmp/$(basename $cfgfile) >> /tmp/confviafile
+test -f /initramfs/machine-setup && \
+ cat /initramfs/machine-setup >> /tmp/confviafile
echo "fileget via $srvproto finished" > /tmp/file-done
}
@@ -497,9 +506,12 @@ waitfor /tmp/file-done 10000 || error "$error_errfcfg" nonfatal
waitfor /tmp/ldap-done 10000 || error "$error_errlcfg" nonfatal
# concat the different files now into the central config file, order
# matters - ldap data has highest priority
-for config in /tmp/confviadhcp /tmp/confviafile /tmp/confvialdap
- do test -f $config && cat $config >> /etc/machine-setup
-done
+if ! [ -f /tmp/cfgcomplete ] ; then
+ for config in /tmp/confviadhcp /tmp/confviafile /tmp/confvialdap
+ do test -f $config && cat $config >> /etc/machine-setup
+ done
+echo "config completed" > /tmp/cfgcomplete
+fi
}
#######################################################################
diff --git a/initrd/initrd-stuff/init b/initrd/initrd-stuff/init
index 9a1dd9a7..a2560b3f 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>, 24-07-2006
+# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 15-08-2006
#
# Copyright: (c) 2006 - RZ Universitaet Freiburg
-# (c) 2006 - odlx.org project
+# (c) 2006 - opendiskless.org project
#
-# Version: 0.2.6d
+# Version: 0.2.6e
# functions common for all distros, messages contains all error and info
# output
@@ -53,7 +53,8 @@ COWSIZE="50%"
RWDIR=/dev/shm
NFSRO="nfs"
-# run pre init script and user defined preinit.local (see Howto)
+# run pre init script and user defined preinit.local, copied by mkdxsinitrd
+# from /var/lib/opendiskless/config/... in stage2
preinit
[ -x /bin/preinit.local ] && /bin/preinit.local
@@ -470,9 +471,11 @@ waitfor /tmp/svcfg 20000 || error "$init_errsw"
# should be killed if started within init
killall -9 dhcpcd dhclient pump 2>/dev/null
cp /etc/machine-setup /mnt/etc
-#bash
-# post init for some distro specific
+
+# post init for some distro specific (fixme!! more elegant solution)
postinit
+[ -s /initramfs/postinit.local ] && \
+ cp /initramfs/postinit.local /bin/postinit.local
[ -x /bin/postinit.local ] && /bin/postinit.local
# start a debug shell in higher debug levels
diff --git a/initrd/mkdxsinitrd b/initrd/mkdxsinitrd
index e3a679a7..f33895c2 100755
--- a/initrd/mkdxsinitrd
+++ b/initrd/mkdxsinitrd
@@ -4,14 +4,14 @@
# ramdisks for linux diskless clients (stage2 system
# setup)
#
-# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 15-08-2006
+# Author(s): Dirk von Suchodoletz <dirk@goe.net>, 16-08-2006
# Nico Dietrich
# Felix Endres
#
# Copyright: (c) 2003 - 2006 - RZ Universitaet Freiburg
-# (c) 2006 - odlx.org project
+# (c) 2006 - opendiskless.org project
#
-# Version: 0.4.5b
+# Version: 0.4.5c
# debug level of script itself
DEBUG=1
@@ -107,7 +107,7 @@ for ELEMENT in bin sbin usr/bin usr/sbin usr/local/bin \
break
fi
done
-return "$RET"
+return $RET
}
# copy some binary to given destination. Takes binary in $1 and
@@ -448,7 +448,7 @@ if [ -n "$use_busybox" ] ; then
ln -s /bin/busybox ${INSTDIR}/bin/$bbins
done
# fake the sh link in busybox environment
- echo -e "#!/bin/ash\n/bin/ash $@" > ${INSTDIR}/bin/sh
+ echo -e "#!/bin/ash\n/bin/ash \$@" > ${INSTDIR}/bin/sh
chmod a+x ${INSTDIR}/bin/sh
else
# find and copy a shell to be used within initialramfs
@@ -471,8 +471,8 @@ else
# needed standard binaries (in init, servconfig, hwautocfg, ... scripts)
for bbins in \
- cat chmod chown chroot cp expr fdisk killall ln ls mkdir mkfs.ext2 \
- modprobe mount rmmod sed sort rm tar umount
+ cat chmod chown chroot cp expr fdisk gzip killall ln ls mkdir \
+ mkfs.ext2 modprobe mount rmmod sed sort rm tar umount
do
cobi ${bbins} bin || echo "Program ${bbins} not found"
done
@@ -488,11 +488,10 @@ else
# tftp client binary for configuration via file - get machine-setup per
# tftp from dhcp (or specified other) server
- #fixme: irgendwann mal nur konditional ...
for tftp in atftp tftp ; do
- binfinder $tftp && break
+ binfinder $tftp && break;
done
- cobi $tftp bin
+ cobi $tftp bin || echo "Program ${tftp} not found"
cp /lib/libnss_files.so.2 ${INSTDIR}/lib
fi
@@ -648,6 +647,10 @@ chmod 755 ${INSTDIR}/init \
if [ -f /var/lib/opendiskless/default/initramfs/machine-setup ] ; then
cp /var/lib/opendiskless/default/initramfs/machine-setup \
${INSTDIR}/etc/machine-setup
+# use the installed default machine-setup.default
+elif [ -f /usr/share/opendiskless/templates/machine-setup.default ] ; then
+ cp /usr/share/opendiskless/templates/machine-setup.default \
+ ${INSTDIR}/etc/machine-setup
# just compatibility for older versions
elif [ -f /etc/dxs/client.cfg/machine-setup.default ] ; then
cp /etc/dxs/client.cfg/machine-setup.default \
@@ -677,14 +680,15 @@ if [ -f /usr/share/opendiskless/templates/Cards.local ] ; then
${INSTDIR}/usr/share/hwdata/Cards
fi
-# finally copy user-supplied preinit files. postinit.local may be
-# part of fileget tgz (in stage3)
-for cfg in ${DISTRO}-${DISTRO_VER}/initramfs/preinit.local \
- default/initramfs/preinit.local \
- ${DISTRO}-${DISTRO_VER}/initramfs/postinit.local \
- default/initramfs/postinit.local ; do
- test -f /var/lib/opendiskless/config/$cfg && {
- cp /var/lib/opendiskless/config/$cfg ${INSTDIR}; break; }
+# finally copy user-supplied preinit files. The client specific one
+# overwrites the system default one. postinit.local may be part of
+# fileget tgz (in stage3)
+for cfg in default/initramfs/preinit.local \
+ ${DISTRO}-${DISTRO_VER}/initramfs/preinit.local \
+ default/initramfs/postinit.local \
+ ${DISTRO}-${DISTRO_VER}/initramfs/postinit.local ; do
+ test -f /var/lib/opendiskless/config/$cfg && \
+ cp /var/lib/opendiskless/config/$cfg ${INSTDIR}/bin
done
# remove unneeded debug info, fixme not really tested yet