summaryrefslogtreecommitdiffstats
path: root/src/boot-env
diff options
context:
space:
mode:
authorSebastian Schmelzer2010-09-02 17:50:49 +0200
committerSebastian Schmelzer2010-09-02 17:50:49 +0200
commit416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5 (patch)
tree4715f7d742fec50931017f38fe6ff0a89d4ceccc /src/boot-env
parentFix for the problem reported on the list (sed filter forgotten for the (diff)
downloadcore-416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5.tar.gz
core-416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5.tar.xz
core-416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5.zip
change dir structure
Diffstat (limited to 'src/boot-env')
-rw-r--r--src/boot-env/OpenSLX/BootEnvironment/Base.pm160
-rw-r--r--src/boot-env/OpenSLX/BootEnvironment/PBS.pm247
-rw-r--r--src/boot-env/OpenSLX/BootEnvironment/PXE.pm336
-rw-r--r--src/boot-env/OpenSLX/BootEnvironment/Preboot.pm209
-rw-r--r--src/boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm111
-rw-r--r--src/boot-env/OpenSLX/BootEnvironment/Preboot/CD.pm155
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Distro/Base.pm48
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Distro/Debian.pm61
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Distro/Scilin.pm61
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Distro/Suse.pm62
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm73
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu_9.pm38
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm453
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Engine/PBS.pm42
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm143
-rw-r--r--src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm264
-rwxr-xr-xsrc/boot-env/pbs/uclib-rootfs/bin/bbinit19
-rwxr-xr-xsrc/boot-env/pbs/uclib-rootfs/bin/handleEvents38
-rwxr-xr-xsrc/boot-env/pbs/uclib-rootfs/etc/bbinit.d/example32
-rw-r--r--src/boot-env/pbs/uclib-rootfs/etc/events/example2
-rwxr-xr-xsrc/boot-env/pbs/uclib-rootfs/init234
-rw-r--r--src/boot-env/pbs/uclib-rootfs/preboot/preboot-scripts/dialog.functions105
-rw-r--r--src/boot-env/preboot/conf/apache-openslx-preboot.conf24
-rwxr-xr-xsrc/boot-env/preboot/http-server/user_settings.pl97
-rwxr-xr-xsrc/boot-env/preboot/http-server/users.pl90
-rw-r--r--src/boot-env/preboot/preboot-scripts/dialog.functions105
-rwxr-xr-xsrc/boot-env/preboot/preboot.sh95
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/init216
l---------src/boot-env/preboot/uclib-rootfs/lib/libcurses.so1
l---------src/boot-env/preboot/uclib-rootfs/lib/libncurses.so1
l---------src/boot-env/preboot/uclib-rootfs/lib/libncurses.so.51
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/lib/libncurses.so.5.6bin0 -> 229164 bytes
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/bin/clearbin0 -> 5156 bytes
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/bin/dialogbin0 -> 108520 bytes
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/bin/w3mbin0 -> 1093832 bytes
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so1
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so.0.9.8bin0 -> 1143120 bytes
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/lib/libcurses.so11
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so1
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.51
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.5.6bin0 -> 39044 bytes
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so1
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.51
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.5.6bin0 -> 21968 bytes
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/lib/libncurses.so11
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so1
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.51
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.5.6bin0 -> 9212 bytes
l---------src/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so1
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so.0.9.8bin0 -> 237392 bytes
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/sbin/kdumpbin0 -> 5200 bytes
-rwxr-xr-xsrc/boot-env/preboot/uclib-rootfs/usr/sbin/kexecbin0 -> 104068 bytes
-rw-r--r--src/boot-env/syslinux/LICENSE3
-rw-r--r--src/boot-env/syslinux/README.iso6
-rw-r--r--src/boot-env/syslinux/README.pxe68
-rwxr-xr-xsrc/boot-env/syslinux/extlinuxbin0 -> 52294 bytes
-rw-r--r--src/boot-env/syslinux/initramfs-shutdownbin0 -> 665088 bytes
-rw-r--r--src/boot-env/syslinux/isolinux.binbin0 -> 14336 bytes
-rw-r--r--src/boot-env/syslinux/kernel-shutdownbin0 -> 688752 bytes
-rwxr-xr-xsrc/boot-env/syslinux/mboot.c32bin0 -> 30380 bytes
-rw-r--r--src/boot-env/syslinux/mbr.binbin0 -> 440 bytes
-rwxr-xr-xsrc/boot-env/syslinux/menu.c32bin0 -> 54836 bytes
-rw-r--r--src/boot-env/syslinux/pxechain.combin0 -> 998 bytes
-rw-r--r--src/boot-env/syslinux/pxelinux.0bin0 -> 16662 bytes
-rw-r--r--src/boot-env/syslinux/pxemenu-bottom.example39
-rw-r--r--src/boot-env/syslinux/pxemenu-include.example58
-rwxr-xr-xsrc/boot-env/syslinux/syslinuxbin0 -> 25472 bytes
-rw-r--r--src/boot-env/syslinux/themes/openslx/openslx.pngbin0 -> 20453 bytes
-rw-r--r--src/boot-env/syslinux/themes/openslx/theme.conf40
-rw-r--r--src/boot-env/syslinux/themes/openslxpbs/openslx.pngbin0 -> 168728 bytes
-rw-r--r--src/boot-env/syslinux/themes/openslxpbs/theme.conf40
-rwxr-xr-xsrc/boot-env/syslinux/vesamenu.c32bin0 -> 147996 bytes
72 files changed, 3807 insertions, 0 deletions
diff --git a/src/boot-env/OpenSLX/BootEnvironment/Base.pm b/src/boot-env/OpenSLX/BootEnvironment/Base.pm
new file mode 100644
index 00000000..aa4cbe5b
--- /dev/null
+++ b/src/boot-env/OpenSLX/BootEnvironment/Base.pm
@@ -0,0 +1,160 @@
+# Copyright (c) 2008 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# BootEnvironment::Base.pm
+# - provides empty base of the BootEnvironment API.
+# -----------------------------------------------------------------------------
+package OpenSLX::BootEnvironment::Base;
+
+use strict;
+use warnings;
+
+our $VERSION = 1.01; # API-version . implementation-version
+
+use Clone qw(clone);
+use File::Basename;
+use File::Path;
+
+use OpenSLX::Basics;
+use OpenSLX::ConfigDB;
+use OpenSLX::MakeInitRamFS::Engine::SlxBoot;
+use OpenSLX::Utils;
+
+our %initramfsMap;
+
+sub new
+{
+ my $class = shift;
+
+ my $self = {};
+
+ return bless $self, $class;
+}
+
+sub initialize
+{
+ my $self = shift;
+ my $params = shift;
+
+ $self->{'dry-run'} = $params->{'dry-run'};
+
+ return 1;
+}
+
+sub finalize
+{
+ my $self = shift;
+ my $delete = shift;
+
+ return 1 if $self->{'dry-run'};
+
+ my $rsyncDeleteClause = $delete ? '--delete' : '';
+ my $rsyncCmd
+ = "rsync -a $rsyncDeleteClause --delay-updates $self->{'target-path'}/ $self->{'original-path'}/";
+ slxsystem($rsyncCmd) == 0
+ or die _tr(
+ "unable to rsync files from '%s' to '%s'! (%s)",
+ $self->{'target-path'}, $self->{'original-path'}, $!
+ );
+ rmtree([$self->{'target-path'}]);
+
+ return 1;
+}
+
+sub requiresDefaultClientConfig
+{
+ my $self = shift;
+
+ return $self->{'requires-default-client-config'};
+}
+
+sub writeBootloaderMenuFor
+{
+ my $self = shift;
+ my $client = shift;
+ my $externalClientID = shift;
+ my $systemInfos = shift;
+
+ return;
+}
+
+sub writeFilesRequiredForBooting
+{
+ my $self = shift;
+ my $info = shift;
+ my $buildPath = shift;
+
+ my $kernelFile = $info->{'kernel-file'};
+ my $kernelName = basename($kernelFile);
+
+ my $vendorOSPath = "$self->{'target-path'}/$info->{'vendor-os'}->{name}";
+ mkpath $vendorOSPath unless -e $vendorOSPath || $self->{'dry-run'};
+
+ my $targetKernel = "$vendorOSPath/$kernelName";
+ if (!-e $targetKernel) {
+ vlog(1, _tr('copying kernel %s to %s', $kernelFile, $targetKernel));
+ slxsystem(qq[cp -p "$kernelFile" "$targetKernel"])
+ unless $self->{'dry-run'};
+ }
+
+ # create initramfs:
+ my $initramfsName = "$vendorOSPath/$info->{'initramfs-name'}";
+ vlog(1, _tr('generating initialramfs %s', $initramfsName));
+ $self->_makeInitRamFS($info, $initramfsName);
+ return 1;
+}
+
+sub _makeInitRamFS
+{
+ my $self = shift;
+ my $info = shift;
+ my $initramfs = shift;
+
+ my $vendorOS = $info->{'vendor-os'};
+ my $kernelFile = basename(followLink($info->{'kernel-file'}));
+
+ my $attrs = clone($info->{attrs} || {});
+
+ chomp(my $slxVersion = qx{slxversion});
+
+ my $params = {
+ 'attrs' => $attrs,
+ 'export-name' => $info->{export}->{name},
+ 'export-uri' => $info->{'export-uri'},
+ 'initramfs' => $initramfs,
+ 'kernel-params'
+ => [ split ' ', ($info->{attrs}->{kernel_params} || '') ],
+ 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '',
+ 'plugins' => $info->{'active-plugins'},
+ 'root-path'
+ => "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}",
+ 'slx-version' => $slxVersion,
+ 'system-name' => $info->{name},
+ };
+
+ # TODO: make debug-level an explicit attribute, it's used in many places!
+ my $kernelParams = $info->{attrs}->{kernel_params} || '';
+ if ($kernelParams =~ m{debug(?:=(\d+))?}) {
+ my $debugLevel = defined $1 ? $1 : '1';
+ $params->{'debug-level'} = $debugLevel;
+ }
+
+ my $makeInitRamFSEngine
+ = OpenSLX::MakeInitRamFS::Engine::SlxBoot->new($params);
+ $makeInitRamFSEngine->execute($self->{'dry-run'});
+
+ # copy back kernel-params, as they might have been changed (by plugins)
+ $info->{attrs}->{kernel_params}
+ = join ' ', $makeInitRamFSEngine->kernelParams();
+
+ return;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/BootEnvironment/PBS.pm b/src/boot-env/OpenSLX/BootEnvironment/PBS.pm
new file mode 100644
index 00000000..2072884b
--- /dev/null
+++ b/src/boot-env/OpenSLX/BootEnvironment/PBS.pm
@@ -0,0 +1,247 @@
+# Copyright (c) 2008 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# BootEnvironment::Preboot.pm
+# - provides general preboot implementation of the BootEnvironment API.
+# -----------------------------------------------------------------------------
+package OpenSLX::BootEnvironment::PBS;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::BootEnvironment::Base);
+
+use OpenSLX::MakeInitRamFS::Engine::PBS;
+
+use Clone qw(clone);
+use File::Basename;
+use File::Path;
+
+use Data::Dumper;
+
+use JSON;
+use HTTP::Request::Common;
+use LWP::UserAgent;
+
+use OpenSLX::Basics;
+use OpenSLX::ConfigDB qw(:support);
+use OpenSLX::Utils;
+
+sub initialize
+{
+ my $self = shift;
+ my $params = shift;
+
+ return if !$self->SUPER::initialize($params);
+
+ $self->{'original-path'} = "$openslxConfig{'public-path'}/pbs";
+ $self->{'target-path'} = "$openslxConfig{'public-path'}/pbs.new";
+
+ $self->{'requires-default-client-config'} = 0;
+ # we do not need a default.tgz since there's always an explicit client
+
+
+ if (!$self->{'dry-run'}) {
+ mkpath([$self->{'original-path'}]);
+ rmtree($self->{'target-path'});
+ mkpath("$self->{'target-path'}/client-config");
+ }
+
+ return 1;
+}
+
+sub writeBootloaderMenuFor
+{
+ my $self = shift;
+ my $client = shift;
+ my $externalClientID = shift;
+ my $systemInfos = shift || [];
+
+ my $prebootSystemInfo
+ = clone($self->_pickSystemWithNewestKernel($systemInfos));
+
+ vlog(
+ 0,
+ _tr(
+ "\nsend preboot information for client '%s' to pbs (%s)\n".
+ " (image templates provided based of %s) ...",
+ $client->{name}, $client->{attrs}->{preboot_server}, $prebootSystemInfo->{name}
+ )
+ );
+
+ $self->_createPrebootStuff($client, $prebootSystemInfo);
+
+ my $kernel = "$self->{'target-path'}/imagebase/vmlinuz";
+ my $initramfs = "$self->{'target-path'}/imagebase/initramfs";
+
+ my $kernel_md5 = qx/md5sum $kernel | awk '{print \$1}'/;
+ my $initramfs_md5 = qx/md5sum $initramfs | awk '{print \$1}'/;
+
+ my $data_json = to_json({
+ 'slxinfo' => qx/slxversion/,
+ 'kernel' => basename($prebootSystemInfo->{'kernel-file'}),
+ 'kernel_md5' => trim($kernel_md5),
+ 'initramfs_md5' => trim($initramfs_md5),
+ 'systems' => $systemInfos
+ });
+ my $ua = LWP::UserAgent->new;
+ my $res = $ua->request(POST 'http://pbs.experimental.openslx.org/backend/system/sync', [data => $data_json]);
+
+ if ($res->is_success) {
+ my $resData = from_json($res->content);
+ if ($resData->{'getKernel'} eq 'fresh') {
+ $res = $ua->request(POST 'http://pbs.experimental.openslx.org/backend/system/addkernel',
+ ['kernel' => basename($prebootSystemInfo->{'kernel-file'}),
+ 'kernelFile' => ["$self->{'target-path'}/imagebase/vmlinuz"],
+ 'initramfsFile' => ["$self->{'target-path'}/imagebase/initramfs"],
+ ],
+ 'Content_Type' => 'form-data'
+ );
+
+ print Dumper($res->content);
+
+ } else {
+ if ($resData->{'getKernel'} eq 'update') {
+ $res = $ua->request(POST 'http://pbs.experimental.openslx.org/backend/system/updatekernel',
+ ['kernel' => basename($prebootSystemInfo->{'kernel-file'}),
+ 'kernelFile' => ["$self->{'target-path'}/imagebase/vmlinuz"],
+ ],
+ 'Content_Type' => 'form-data'
+ );
+
+ print Dumper($res->content);
+ } else {
+ # do nothing
+ }
+ if ($resData->{'getInitramfs'} eq 'update') {
+ $res = $ua->request(POST 'http://pbs.experimental.openslx.org/backend/system/updateinitramfs',
+ ['kernel' => basename($prebootSystemInfo->{'kernel-file'}),
+ 'initramfsFile' => ["$self->{'target-path'}/imagebase/initramfs"],
+ ],
+ 'Content_Type' => 'form-data'
+ );
+
+ print Dumper($res->content);
+ } else {
+ # do nothing
+ }
+ }
+ } else {
+ vlog(0, 'communication with pbs failed.. please check and rerun..');
+ }
+
+ return 1;
+}
+
+sub _createPrebootStuff
+{
+ my $self = shift;
+ my $client = shift;
+ my $info = shift;
+
+ my $prebootClass = instantiateClass(
+ "OpenSLX::BootEnvironment::Preboot::Base"
+ );
+
+ my $imagebase = "$self->{'target-path'}/imagebase";
+
+ $prebootClass->initialize($self);
+ $client->{attrs}->{boot_uri} = $client->{attrs}->{preboot_server};
+ mkpath("$imagebase");
+ $self->_makePBSInitRamFS($info, "$imagebase/initramfs", $client);
+
+ my $kernelFile = $info->{'kernel-file'};
+ my $kernelName = basename($kernelFile);
+ slxsystem(qq{cp -p "$kernelFile" "$imagebase/vmlinuz"})
+ unless $self->{'dry-run'};
+
+ return 1;
+}
+
+sub _pickSystemWithNewestKernel
+{
+ my $self = shift;
+ my $systemInfos = shift;
+
+ my $systemWithNewestKernel;
+ my $newestKernelFileSortKey = '';
+ foreach my $system (@$systemInfos) {
+ next unless $system->{'kernel-file'} =~ m{
+ (?:vmlinuz|x86)-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?)
+ }x;
+ my $sortKey
+ = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5);
+ if ($newestKernelFileSortKey lt $sortKey) {
+ $systemWithNewestKernel = $system;
+ $newestKernelFileSortKey = $sortKey;
+ }
+ }
+
+ if (!defined $systemWithNewestKernel) {
+ die _tr("unable to pick a system to be used for preboot!");
+ }
+ return $systemWithNewestKernel;
+}
+
+sub _makePBSInitRamFS
+{
+ my $self = shift;
+ my $info = shift;
+ my $initramfs = shift;
+ my $client = shift;
+
+ my $vendorOS = $info->{'vendor-os'};
+ my $kernelFile = basename(followLink($info->{'kernel-file'}));
+
+ my $attrs = clone($info->{attrs} || {});
+
+ my $bootURI = $client->{attrs}->{boot_uri};
+ if (!$bootURI) {
+ die _tr("client $client->{name} needs an URI in attribute 'boot_uri' to be used for preboot!");
+ }
+
+ chomp(my $slxVersion = qx{slxversion});
+
+ my $params = {
+ 'attrs' => $attrs,
+ 'export-name' => undef,
+ 'export-uri' => undef,
+ 'initramfs' => $initramfs,
+ 'kernel-params'
+ => [ split ' ', ($info->{attrs}->{kernel_params} || '') ],
+ 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '',
+ 'plugins' => '',
+ 'root-path'
+ => "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}",
+ 'slx-version' => $slxVersion,
+ 'system-name' => $info->{name},
+ 'preboot-id' => $client->{name},
+ 'boot-uri' => $bootURI,
+ };
+
+ # TODO: make debug-level an explicit attribute, it's used in many places!
+ my $kernelParams = $info->{attrs}->{kernel_params} || '';
+ if ($kernelParams =~ m{debug(?:=(\d+))?}) {
+ my $debugLevel = defined $1 ? $1 : '1';
+ $params->{'debug-level'} = $debugLevel;
+ }
+
+ my $makeInitRamFSEngine
+ = OpenSLX::MakeInitRamFS::Engine::PBS->new($params);
+ $makeInitRamFSEngine->execute($self->{'dry-run'});
+
+ # copy back kernel-params, as they might have been changed (by plugins)
+ $info->{attrs}->{kernel_params}
+ = join ' ', $makeInitRamFSEngine->kernelParams();
+
+ return;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/BootEnvironment/PXE.pm b/src/boot-env/OpenSLX/BootEnvironment/PXE.pm
new file mode 100644
index 00000000..d46786d0
--- /dev/null
+++ b/src/boot-env/OpenSLX/BootEnvironment/PXE.pm
@@ -0,0 +1,336 @@
+# Copyright (c) 2008..2009 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# BootEnvironment::PXE.pm
+# - provides PXE-specific implementation of the BootEnvironment API.
+# -----------------------------------------------------------------------------
+package OpenSLX::BootEnvironment::PXE;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::BootEnvironment::Base);
+
+use File::Basename;
+use File::Path;
+# for sha1 passwd encryption
+use Digest::SHA1;
+use MIME::Base64;
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+sub initialize
+{
+ my $self = shift;
+ my $params = shift;
+
+ return if !$self->SUPER::initialize($params);
+
+ $self->{'original-path'} = "$openslxConfig{'public-path'}/tftpboot";
+ $self->{'target-path'} = "$openslxConfig{'public-path'}/tftpboot.new";
+
+ $self->{'requires-default-client-config'} = 1;
+
+ if (!$self->{'dry-run'}) {
+ mkpath([$self->{'original-path'}]);
+ rmtree($self->{'target-path'});
+ mkpath("$self->{'target-path'}/client-config");
+ }
+
+ return 1;
+}
+
+sub writeBootloaderMenuFor
+{
+ my $self = shift;
+ my $client = shift;
+ my $externalClientID = shift;
+ my $systemInfos = shift;
+
+ $self->_prepareBootloaderConfigFolder()
+ unless $self->{preparedBootloaderConfigFolder};
+
+ my $pxePath = $self->{'target-path'};
+ my $pxeConfigPath = "$pxePath/pxelinux.cfg";
+
+ my $pxeConfig = $self->_getTemplate();
+ my $pxeFile = "$pxeConfigPath/$externalClientID";
+ my $clientAppend = $client->{attrs}->{kernel_params_client} || '';
+ my $bootURI = $client->{attrs}->{boot_uri} || '';
+ vlog(1, _tr("writing PXE-file %s", $pxeFile));
+
+ # set label for each system
+ foreach my $info (@$systemInfos) {
+ my $label = $info->{label} || '';
+ if (!length($label) || $label eq $info->{name}) {
+ if ($info->{name} =~ m{^(.+)::(.+)$}) {
+ my $system = $1;
+ my $exportType = $2;
+ $label = $system . ' ' x (40-length($system)) . $exportType;
+ } else {
+ $label = $info->{name};
+ }
+ }
+ $info->{menuLabel} = $label;
+ }
+# if kernel=*xen* then run sub _xenLabel from xen.pm
+ my $slxLabels = '';
+ foreach my $info (sort { $a->{label} cmp $b->{label} } @$systemInfos) {
+ my $vendorOSName = $info->{'vendor-os'}->{name};
+ my $kernelName = basename($info->{'kernel-file'});
+ my $append = $info->{attrs}->{kernel_params};
+ my $pxeLabel = $info->{'external-id'};
+ $pxeLabel =~ s/::/-/g;
+ my $pxePrefix = '';
+ my $tftpPrefix = '';
+ $info->{'pxe_prefix_ip'} ||= '';
+
+ # pxe_prefix_ip set and looks like a ip
+ if ($info->{'pxe_prefix_ip'} =~ m/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {
+ $pxePrefix = "$info->{'pxe_prefix_ip'}::";
+ $tftpPrefix = "tftp://$info->{'pxe_prefix_ip'}"
+ if ! length($bootURI);
+ }
+
+ # set default menu entry
+ my $pxeDefault = "";
+ if (defined $openslxConfig{'pxe-default-menu-entry'}) {
+ if ($openslxConfig{'pxe-default-menu-entry'} eq
+ $info->{'external-id'})
+ {
+ $pxeDefault = "\tMENU DEFAULT\n";
+ }
+ }
+ $append .= " initrd=$pxePrefix$vendorOSName/$info->{'initramfs-name'}";
+ $append .= " file=$bootURI" if length($bootURI);
+ $append .= " file=$tftpPrefix" if length($tftpPrefix);
+ $append .= " $clientAppend";
+ $slxLabels .= "LABEL openslx-$pxeLabel\n";
+ $slxLabels .= $pxeDefault;
+ $slxLabels .= "\tMENU LABEL ^$info->{menuLabel}\n";
+ $slxLabels .= "\tKERNEL $pxePrefix$vendorOSName/$kernelName\n";
+ $slxLabels .= "\tAPPEND $append\n";
+ $slxLabels .= "\tIPAPPEND 3\n";
+# if kernel=*xen* then run sub _xenBootEntry from xen.pm
+# if (!defined $xenKernel) {...}
+ my $helpText = $info->{description} || '';
+ if (length($helpText)) {
+ # make sure that text matches the given margin
+ my $menuMargin;
+ while ($pxeConfig =~ m{^\s*MENU MARGIN (\S+?)\s*$}gims) {
+ chomp($menuMargin = $1);
+ }
+ my $margin
+ = defined $menuMargin
+ ? "$menuMargin"
+ : "0";
+ my $marginAsText = ' ' x $margin;
+
+ my $menuWidth;
+ while ($pxeConfig =~ m{^\s*MENU WIDTH (\S+?)\s*$}gims) {
+ chomp($menuWidth = $1);
+ }
+ my $width
+ = defined $menuWidth
+ ? "$menuWidth"
+ : "80";
+ $width = $width - 2* $margin + 2;
+
+ my @atomicHelpText = split(/ /, $helpText);
+ my $lineCounter = 0;
+
+ $helpText = "";
+
+ foreach my $word (@atomicHelpText){
+ if ($lineCounter + length($word) + 1 < $width) {
+ $helpText .= "$word ";
+ $lineCounter += length($word) + 1;
+ } else {
+ my $nobreak = 1;
+ while ($nobreak == 1) {
+ my $pos = index($word,"-");
+ $nobreak = 0;
+ if ($pos != -1) {
+ if ($lineCounter + $pos + 1 < $width) {
+ $helpText .= substr($word, 0, $pos+1);
+ $word = substr($word, $pos + 1, length($word));
+ $nobreak = 1;
+ }
+ }
+ }
+ $helpText .= "\n$word ";
+ $lineCounter = length($word);
+ }
+ }
+
+ $helpText =~ s{^}{$marginAsText}gms;
+ $slxLabels .= "\tTEXT HELP\n";
+ $slxLabels .= "$helpText\n";
+ $slxLabels .= "\tENDTEXT\n";
+ }
+ }
+ # now add the slx-labels (inline or appended) and write the config file
+ if (!($pxeConfig =~ s{\@\@\@SLX_LABELS\@\@\@}{$slxLabels})) {
+ $pxeConfig .= $slxLabels;
+ # fetch PXE-bottom iclude, if exists (overwrite existing definitions)
+ my $pxeBottomFile
+ = "$openslxConfig{'config-path'}/boot-env/syslinux/pxemenu-bottom";
+ if (-e $pxeBottomFile) {
+ $pxeConfig .= "\n# configuration from include $pxeBottomFile\n";
+ $pxeConfig .= slurpFile($pxeBottomFile);
+ }
+ }
+
+ # PXE uses 'cp850' (codepage 850) but our string is in utf-8, we have
+ # to convert in order to avoid showing gibberish on the client side...
+ spitFile($pxeFile, $pxeConfig, { 'io-layer' => 'encoding(cp850)' } )
+ unless $self->{'dry-run'};
+
+ return 1;
+}
+
+sub _getTemplate
+{
+ my $self = shift;
+
+ return $self->{'pxe-template'} if $self->{'pxe-template'};
+
+ my $basePath = $openslxConfig{'base-path'};
+ my $configPath = $openslxConfig{'config-path'};
+ my $pxeTheme = $openslxConfig{'syslinux-theme'};
+
+ my ($sec, $min, $hour, $day, $mon, $year) = (localtime);
+ $mon++;
+ $year += 1900;
+ my $callDate = sprintf('%04d-%02d-%02d', $year, $mon, $day);
+ my $callTime = sprintf('%02d:%02d:%02d', $hour, $min, $sec);
+
+ # generate PXE-Menu
+ my $pxeTemplate =
+ "# generated by slxconfig-demuxer (on $callDate at $callTime)\n";
+ $pxeTemplate .= "\nDEFAULT vesamenu.c32\n";
+ # include static defaults
+ $pxeTemplate .= "\n# static configuration (override with include file)\n";
+ $pxeTemplate .= "NOESCAPE 0\n";
+ $pxeTemplate .= "PROMPT 0\n";
+
+ # first check for theme
+ # let user stuff in config path win over our stuff in base path
+ my $pxeThemePath;
+ my $pxeThemeInConfig
+ = "$configPath/boot-env/syslinux/themes/${pxeTheme}";
+ my $pxeThemeInBase
+ = "$basePath/share/boot-env/syslinux/themes/${pxeTheme}";
+ if (-e "$pxeThemeInConfig/theme.conf") {
+ $pxeThemePath = $pxeThemeInConfig;
+ }
+ else {
+ if (-e "$pxeThemeInBase/theme.conf") {
+ $pxeThemePath = $pxeThemeInBase;
+ }
+ }
+ # include theme specific stuff
+ if (defined $pxeThemePath) {
+ $pxeTemplate .= "\n# theme specific configuration from $pxeThemePath\n";
+ $pxeTemplate .= slurpFile("$pxeThemePath/theme.conf");
+ }
+
+ # copy background picture if exists
+ my $pic;
+ if (defined $pxeTheme) {
+ while ($pxeTemplate =~ m{^\s*MENU BACKGROUND (\S+?)\s*$}gims) {
+ chomp($pic = $1);
+ }
+ }
+ if (defined $pic) {
+ my $pxeBackground = "$pxeThemePath/$pic";
+ if (-e $pxeBackground && !$self->{'dry-run'}) {
+ slxsystem(qq[cp "$pxeBackground" $self->{'target-path'}/]);
+ }
+ }
+
+ # include slxsettings
+ $pxeTemplate .= "\n# slxsettings configuration\n";
+ $pxeTemplate .= "TIMEOUT $openslxConfig{'pxe-timeout'}\n" || "";
+ $pxeTemplate .= "TOTALTIMEOUT $openslxConfig{'pxe-totaltimeout'}\n" || "";
+ my $sha1pass = $self->_sha1pass($openslxConfig{'pxe-passwd'});
+ $pxeTemplate .= "MENU MASTER PASSWD $sha1pass\n" || "";
+ $pxeTemplate .= "MENU TITLE $openslxConfig{'pxe-title'}\n" || "";
+
+ # fetch PXE-include, if exists (overwrite existing definitions)
+ my $pxeIncludeFile
+ = "$openslxConfig{'config-path'}/boot-env/syslinux/pxemenu-include";
+ if (-e $pxeIncludeFile) {
+ $pxeTemplate .= "\n# configuration from include $pxeIncludeFile\n";
+ $pxeTemplate .= slurpFile($pxeIncludeFile);
+ }
+
+ $pxeTemplate .= "\n# slxsystems:\n";
+ $self->{'pxe-template'} = $pxeTemplate;
+
+ return $pxeTemplate;
+}
+
+sub _prepareBootloaderConfigFolder
+{
+ my $self = shift;
+
+ my $basePath = $openslxConfig{'base-path'};
+ my $pxePath = $self->{'target-path'};
+ my $pxeConfigPath = "$pxePath/pxelinux.cfg";
+
+ if (!$self->{'dry-run'}) {
+ rmtree($pxeConfigPath);
+ mkpath($pxeConfigPath);
+
+ for my $file ('pxelinux.0', 'pxechain.com', 'vesamenu.c32',
+ 'mboot.c32', 'kernel-shutdown', 'initramfs-shutdown') {
+ if (!-e "$pxePath/$file") {
+ slxsystem(
+ qq[cp -p "$basePath/share/boot-env/syslinux/$file" $pxePath/]
+ );
+ }
+ }
+ }
+
+ $self->{preparedBootloaderConfigFolder} = 1;
+
+ return 1;
+}
+
+# from syslinux 3.73: http://syslinux.zytor.com
+sub _random_bytes
+{
+ my $self = shift;
+ my $n = shift;
+ my($v, $i);
+
+ # using perl rand because of problems with encoding(cp850) and 'bytes'
+ srand($$ ^ time);
+ $v = '';
+ for ( $i = 0 ; $i < $n ; $i++ ) {
+ $v .= ord(int(rand() * 256));
+ }
+
+ return $v;
+}
+
+sub _sha1pass
+{
+ my $self = shift;
+ my $pass = shift;
+ my $salt = shift || MIME::Base64::encode($self->_random_bytes(6), '');
+ $pass = Digest::SHA1::sha1_base64($salt, $pass);
+
+ return sprintf('$4$%s$%s$', $salt, $pass);
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/BootEnvironment/Preboot.pm b/src/boot-env/OpenSLX/BootEnvironment/Preboot.pm
new file mode 100644
index 00000000..b06de7d2
--- /dev/null
+++ b/src/boot-env/OpenSLX/BootEnvironment/Preboot.pm
@@ -0,0 +1,209 @@
+# Copyright (c) 2008 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# BootEnvironment::Preboot.pm
+# - provides general preboot implementation of the BootEnvironment API.
+# -----------------------------------------------------------------------------
+package OpenSLX::BootEnvironment::Preboot;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::BootEnvironment::Base);
+
+use Clone qw(clone);
+use File::Basename;
+use File::Path;
+
+use OpenSLX::Basics;
+use OpenSLX::ConfigDB qw(:support);
+use OpenSLX::Utils;
+
+sub initialize
+{
+ my $self = shift;
+ my $params = shift;
+
+ return if !$self->SUPER::initialize($params);
+
+ $self->{'original-path'} = "$openslxConfig{'public-path'}/preboot";
+ $self->{'target-path'} = "$openslxConfig{'public-path'}/preboot.new";
+
+ $self->{'requires-default-client-config'} = 0;
+ # we do not need a default.tgz since there's always an explicit client
+
+ if (!$self->{'dry-run'}) {
+ mkpath([$self->{'original-path'}]);
+ rmtree($self->{'target-path'});
+ mkpath("$self->{'target-path'}/client-config");
+ }
+
+ return 1;
+}
+
+sub writeBootloaderMenuFor
+{
+ my $self = shift;
+ my $client = shift;
+ my $externalClientID = shift;
+ my $systemInfos = shift || [];
+
+ $self->_prepareBootloaderConfigFolder()
+ unless $self->{preparedBootloaderConfigFolder};
+
+ my $prebootSystemInfo
+ = clone($self->_pickSystemWithNewestKernel($systemInfos));
+
+ $self->_createImages($client, $prebootSystemInfo);
+
+ my $externalClientName = externalConfigNameForClient($client);
+ my $bootloaderPath = "$self->{'target-path'}/bootloader";
+ my $bootloaderConfigPath = "$bootloaderPath/$externalClientName";
+ mkpath($bootloaderConfigPath) unless $self->{'dry-run'};
+ my $menuFile = "$bootloaderConfigPath/bootmenu.dialog";
+
+ my $clientAppend = $client->{attrs}->{kernel_params_client} || '';
+ vlog(1, _tr("writing bootmenu %s", $menuFile));
+
+ # set label for each system
+ foreach my $info (@$systemInfos) {
+ my $label = $info->{label} || '';
+ if (!length($label) || $label eq $info->{name}) {
+ $label = $info->{name};
+ }
+ $info->{label} = $label;
+ }
+ my $bootmenuEntries = '';
+ my $entryState = 'on';
+ my $counter = 1;
+ foreach my $info (sort { $a->{label} cmp $b->{label} } @$systemInfos) {
+ my $vendorOSName = $info->{'vendor-os'}->{name};
+ my $kernelName = basename($info->{'kernel-file'});
+ my $append = $info->{attrs}->{kernel_params} || '';
+ $append .= " $clientAppend";
+ $bootmenuEntries .= qq{ "$counter" "$info->{label}" };
+ $entryState = 'off';
+
+ # create a file containing the boot-configuration for this system
+ my $systemDescr = unshiftHereDoc(<<" End-of-Here");
+ label="$info->{label}"
+ kernel="$vendorOSName/$kernelName"
+ initramfs="$vendorOSName/$info->{'initramfs-name'}"
+ append="$append"
+ End-of-Here
+ my $systemFile = "$bootloaderConfigPath/$info->{name}";
+ spitFile(
+ $systemFile, $systemDescr, { 'io-layer' => 'encoding(iso8859-1)' }
+ ) unless $self->{'dry-run'};
+ slxsystem(qq{ln -sf $info->{name} $bootloaderConfigPath/$counter});
+ $counter++;
+ }
+
+ my $entryCount = @$systemInfos;
+ my $bootmenu = unshiftHereDoc(<<" End-of-Here");
+ --no-cancel --menu "OpenSLX Boot Menu" 20 65 $entryCount $bootmenuEntries
+ End-of-Here
+
+ if (!$self->{'dry-run'}) {
+ # default to iso encoding, let's see how uclibc copes with it ...
+ spitFile($menuFile, $bootmenu, { 'io-layer' => 'encoding(iso8859-1)' });
+
+ # copy the preboot script into the folder to be tared
+ my $prebootBasePath
+ = "$openslxConfig{'base-path'}/share/boot-env/preboot";
+ slxsystem(qq{cp $prebootBasePath/preboot.sh $bootloaderConfigPath/});
+ slxsystem(qq{cp -r $prebootBasePath/preboot-scripts $bootloaderConfigPath/});
+ slxsystem(qq{chmod a+x $bootloaderConfigPath/preboot.sh});
+
+ # create a tar which can/will be downloaded by prebooting clients
+ my $tarCMD
+ = qq{cd $bootloaderConfigPath; tar -czf "${bootloaderConfigPath}.env" *};
+ slxsystem($tarCMD);
+ rmtree($bootloaderConfigPath);
+ }
+
+ return 1;
+}
+
+sub _createImages
+{
+ my $self = shift;
+ my $client = shift;
+ my $info = shift;
+
+ my %mediaMap = (
+ 'cd' => 'CD',
+ );
+ my $prebootMedia = $client->{attrs}->{preboot_media} || '';
+ if (!$prebootMedia) {
+ warn _tr(
+ "no preboot-media defined for client %s, no images will be generated!",
+ $client->{name}
+ );
+ return 0;
+ }
+ foreach my $mediumName (split m{, }, $prebootMedia) {
+ my $moduleName = $mediaMap{$mediumName}
+ or die _tr(
+ "'%s' is not one of the supported preboot-medias (cd)",
+ $mediumName
+ );
+
+ my $prebootMedium = instantiateClass(
+ "OpenSLX::BootEnvironment::Preboot::$moduleName"
+ );
+ $prebootMedium->initialize($self);
+ $prebootMedium->createImage($client, $info);
+ }
+
+ return 1;
+}
+
+sub _prepareBootloaderConfigFolder
+{
+ my $self = shift;
+
+ my $bootloaderPath = "$self->{'target-path'}/bootloader";
+ if (!$self->{'dry-run'}) {
+ rmtree($bootloaderPath);
+ mkpath($bootloaderPath);
+ }
+
+ $self->{preparedBootloaderConfigFolder} = 1;
+
+ return 1;
+}
+
+sub _pickSystemWithNewestKernel
+{
+ my $self = shift;
+ my $systemInfos = shift;
+
+ my $systemWithNewestKernel;
+ my $newestKernelFileSortKey = '';
+ foreach my $system (@$systemInfos) {
+ next unless $system->{'kernel-file'} =~ m{
+ (?:vmlinuz|x86)-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?)
+ }x;
+ my $sortKey
+ = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5);
+ if ($newestKernelFileSortKey lt $sortKey) {
+ $systemWithNewestKernel = $system;
+ $newestKernelFileSortKey = $sortKey;
+ }
+ }
+
+ if (!defined $systemWithNewestKernel) {
+ die _tr("unable to pick a system to be used for preboot!");
+ }
+ return $systemWithNewestKernel;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm b/src/boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm
new file mode 100644
index 00000000..89f0e07e
--- /dev/null
+++ b/src/boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm
@@ -0,0 +1,111 @@
+# Copyright (c) 2008-2009 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# BootEnvironment::Preboot::Base.pm
+# - base of the Preboot-BootEnvironment API.
+# -----------------------------------------------------------------------------
+package OpenSLX::BootEnvironment::Preboot::Base;
+
+use strict;
+use warnings;
+
+use File::Basename;
+
+use Clone qw(clone);
+
+use OpenSLX::Basics;
+use OpenSLX::MakeInitRamFS::Engine::Preboot;
+use OpenSLX::Utils;
+
+sub new
+{
+ my $class = shift;
+
+ my $self = {};
+
+ return bless $self, $class;
+}
+
+sub initialize
+{
+ my $self = shift;
+ my $params = shift;
+
+ $self->{'dry-run'} = $params->{'dry-run'};
+
+ return 1;
+}
+
+sub makePrebootInitRamFS
+{
+ my $self = shift;
+ my $info = shift;
+ my $initramfs = shift;
+ my $client = shift;
+
+ my $vendorOS = $info->{'vendor-os'};
+ my $kernelFile = basename(followLink($info->{'kernel-file'}));
+
+ my $attrs = clone($info->{attrs} || {});
+
+ my $bootURI = $client->{attrs}->{boot_uri};
+ if (!$bootURI) {
+ die _tr("client $client->{name} needs an URI in attribute 'boot_uri' to be used for preboot!");
+ }
+
+ chomp(my $slxVersion = qx{slxversion});
+
+ my $params = {
+ 'attrs' => $attrs,
+ 'export-name' => undef,
+ 'export-uri' => undef,
+ 'initramfs' => $initramfs,
+ 'kernel-params'
+ => [ split ' ', ($info->{attrs}->{kernel_params} || '') ],
+ 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '',
+ 'plugins' => '',
+ 'root-path'
+ => "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}",
+ 'slx-version' => $slxVersion,
+ 'system-name' => $info->{name},
+ 'preboot-id' => $client->{name},
+ 'boot-uri' => $bootURI,
+ };
+
+ # TODO: make debug-level an explicit attribute, it's used in many places!
+ my $kernelParams = $info->{attrs}->{kernel_params} || '';
+ if ($kernelParams =~ m{debug(?:=(\d+))?}) {
+ my $debugLevel = defined $1 ? $1 : '1';
+ $params->{'debug-level'} = $debugLevel;
+ }
+
+ my $makeInitRamFSEngine
+ = OpenSLX::MakeInitRamFS::Engine::Preboot->new($params);
+ $makeInitRamFSEngine->execute($self->{'dry-run'});
+
+ # copy back kernel-params, as they might have been changed (by plugins)
+ $info->{attrs}->{kernel_params}
+ = join ' ', $makeInitRamFSEngine->kernelParams();
+
+ return;
+}
+
+sub createImage
+{
+ my $self = shift;
+ my $client = shift;
+ my $info = shift;
+
+ # override in subclasses!
+
+ return 1;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/BootEnvironment/Preboot/CD.pm b/src/boot-env/OpenSLX/BootEnvironment/Preboot/CD.pm
new file mode 100644
index 00000000..a6c36cd7
--- /dev/null
+++ b/src/boot-env/OpenSLX/BootEnvironment/Preboot/CD.pm
@@ -0,0 +1,155 @@
+# Copyright (c) 2008-2009 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# BootEnvironment::Preboot::CD.pm
+# - provides CD-specific implementation of the Preboot-BootEnvironment API.
+# -----------------------------------------------------------------------------
+package OpenSLX::BootEnvironment::Preboot::CD;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::BootEnvironment::Preboot::Base);
+
+use File::Basename;
+use File::Path;
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+sub createImage
+{
+ my $self = shift;
+ my $client = shift;
+ my $info = shift;
+
+ vlog(
+ 0,
+ _tr(
+ "\ncreating CD-image for client %s (based on %s) ...",
+ $client->{name}, $info->{name}
+ )
+ );
+
+ my $imageDir = "$openslxConfig{'public-path'}/images/$client->{name}/cd";
+ my $isoDir = "$imageDir/iso/isolinux";
+ mkpath($isoDir) unless $self->{'dry-run'};
+
+ # copy static data
+ my $dataDir = "$openslxConfig{'base-path'}/share/boot-env/syslinux";
+ for my $file ('LICENSE', 'README.iso', 'vesamenu.c32', 'isolinux.bin') {
+ if (!-e "$isoDir/$file") {
+ slxsystem(
+ qq[cp -p "$dataDir/$file" "$isoDir/"]
+ )
+ unless $self->{'dry-run'};
+ }
+ }
+
+ # copy kernel (take the one from the given system info)
+ my $kernelFile = $info->{'kernel-file'};
+ my $kernelName = basename($kernelFile);
+ slxsystem(qq{cp -p "$kernelFile" "$isoDir/vmlinuz"})
+ unless $self->{'dry-run'};
+
+ # create initramfs
+ my $initramfsName = qq{"$isoDir/initramfs"};
+ $self->makePrebootInitRamFS($info, $initramfsName, $client);
+
+ # write trivial isolinux config
+ # include static defaults
+ my $isolinuxConfig = "DEFAULT vesamenu.c32\n";
+ $isolinuxConfig .= "PROMPT 0\n";
+ $isolinuxConfig .= "TIMEOUT 100\n";
+
+ # theme stuff
+ my $basePath = $openslxConfig{'base-path'};
+ my $configPath = $openslxConfig{'config-path'};
+ my $isoTheme = $openslxConfig{'syslinux-theme'};
+
+ my $isoThemePath;
+ my $isoThemeInConfig
+ = "$configPath/boot-env/syslinux/themes/${isoTheme}";
+ my $isoThemeInBase
+ = "$basePath/share/boot-env/syslinux/themes/${isoTheme}";
+ if (-e "$isoThemeInConfig/theme.conf") {
+ $isoThemePath = $isoThemeInConfig;
+ }
+ else {
+ if (-e "$isoThemeInBase/theme.conf") {
+ $isoThemePath = $isoThemeInBase;
+ }
+ }
+ # include theme specific stuff
+ if (defined $isoThemePath) {
+ $isolinuxConfig .= slurpFile("$isoThemePath/theme.conf");
+ }
+
+ # copy background picture if exists
+ my $pic;
+ if (defined $isoTheme) {
+ while ($isolinuxConfig =~ m{^\s*MENU BACKGROUND (\S+?)\s*$}gims) {
+ chomp($pic = $1);
+ }
+ }
+ if (defined $pic) {
+ my $isoBackground = "$isoThemePath/$pic";
+ if (-e $isoBackground && !$self->{'dry-run'}) {
+ slxsystem(qq[cp "$isoBackground" "$isoDir/"]);
+ }
+ }
+
+ # write trivial isolinux config
+ $isolinuxConfig .= unshiftHereDoc(<<" End-of-Here");
+ MENU TITLE Welcome to OpenSLX PreBoot ISO/CD (Mini Linux/Kexec)
+ LABEL SLXSTDBOOT
+ MENU LABEL OpenSLX PreBoot - Stateless Netboot Linux ...
+ MENU DEFAULT
+ KERNEL vmlinuz
+ APPEND initrd=initramfs vga=0x317
+ TEXT HELP
+ Use this (default) entry if you have configured your client.
+ You have chance to edit the kernel commandline by hitting
+ the TAB key (e.g. for adding debug=3 to it for bug hunting).
+ ENDTEXT
+ LABEL LOCALBOOT
+ MENU LABEL Boot locally (skip OpenSLX PreBoot) ...
+ LOCALBOOT -1
+ TEXT HELP
+ Gets you out of here by booting from next device in BIOS
+ boot order.
+ ENDTEXT
+ End-of-Here
+ spitFile("$isoDir/isolinux.cfg", $isolinuxConfig);
+
+ my $mkisoCmd = unshiftHereDoc(<<" End-of-Here");
+ mkisofs
+ -o "$imageDir/../$client->{name}.iso"
+ -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4
+ -r -J -l -boot-info-table -joliet-long
+ -publisher "OpenSLX Project - http://www.openslx.org"
+ -p "OpenSLX Project - openslx-devel\@openslx.org"
+ -V "OpenSLX BootISO"
+ -volset "OpenSLX Project - PreBoot ISO/CD for non PXE/TFTP start of a Linux Stateless Client"
+ -c isolinux/boot.cat "$imageDir/iso"
+ End-of-Here
+ $mkisoCmd =~ s{\n\s*}{ }gms;
+ my $logFile = "$imageDir/../$client->{name}.iso.log";
+ if (slxsystem(qq{$mkisoCmd 2>"$logFile"})) {
+ my $log = slurpFile($logFile);
+ die _tr("unable to create ISO-image - log follows:\n%s", $log);
+ }
+
+ rmtree($imageDir);
+
+ return 1;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Base.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Base.pm
new file mode 100644
index 00000000..9be218e8
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Base.pm
@@ -0,0 +1,48 @@
+# 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitRamFS::Distro::Base.pm
+# - provides empty base of the distro-specific part of the OpenSLX
+# MakeInitRamFS API.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Distro::Base;
+
+use strict;
+use warnings;
+
+our $VERSION = 1.01; # API-version . implementation-version
+
+use OpenSLX::Basics;
+
+################################################################################
+### interface methods
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'base',
+ };
+ return bless $self, $class;
+}
+
+sub applyChanges
+{
+}
+
+sub determineMatchingHwinfoVersion
+{
+ my $self = shift;
+ my $distroVersion = shift;
+
+ return '15.3';
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Debian.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Debian.pm
new file mode 100644
index 00000000..7174474d
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Debian.pm
@@ -0,0 +1,61 @@
+# Copyright (c) 2006..2010 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitRamFS::Distro::Debian.pm
+# - provides Debian-specific overrides of the MakeInitRamFS::Distro API.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Distro::Debian;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'debian',
+ };
+ return bless $self, $class;
+}
+
+sub applyChanges
+{
+ my $self = shift;
+ my $engine = shift;
+
+ $engine->_addFilteredKernelModules( qw( af_packet hid hid-bright unix ));
+
+ return;
+}
+
+sub determineMatchingHwinfoVersion
+{
+ my $self = shift;
+ my $distroVersion = shift;
+
+ # to be checked
+ my %versionMap = (
+ '3.0' => '13.11',
+ '4.0' => '14.19',
+ '5.0' => '15.3',
+ '6.0' => '16.0',
+ );
+ return $versionMap{$distroVersion}
+ || $self->SUPER::determineMatchingHwinfoVersion($distroVersion);
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Scilin.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Scilin.pm
new file mode 100644
index 00000000..f2372f8f
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Scilin.pm
@@ -0,0 +1,61 @@
+# Copyright (c) 2009..2010 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitRamFS::Distro::Scilin.pm
+# - provides Scientific Linux specific overrides of the
+# MakeInitRamFS::Distro API.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Distro::Scilin;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'scilin',
+ };
+ return bless $self, $class;
+}
+
+sub applyChanges
+{
+ my $self = shift;
+ my $engine = shift;
+ # filter modules which are part of the main kernel already
+ $engine->_addFilteredKernelModules( qw( af_packet hid hid-bright usbhid unix vesafb fbcon ));
+
+ return;
+}
+
+sub determineMatchingHwinfoVersion
+{
+ my $self = shift;
+ my $distroVersion = shift;
+
+ my %versionMap = (
+ '4.7' => '13.11',
+ '5.3' => '15.3',
+ '5.4' => '15.21',
+ '5.5' => '16.0',
+ );
+ return $versionMap{$distroVersion}
+ || $self->SUPER::determineMatchingHwinfoVersion($distroVersion);
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Suse.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Suse.pm
new file mode 100644
index 00000000..cb106924
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Suse.pm
@@ -0,0 +1,62 @@
+# Copyright (c) 2006..2010 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitRamFS::Distro::SUSE.pm
+# - provides SUSE-specific overrides of the MakeInitRamFS::Distro API.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Distro::Suse;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'suse',
+ };
+ return bless $self, $class;
+}
+
+sub applyChanges
+{
+ my $self = shift;
+ my $engine = shift;
+
+ $engine->_addFilteredKernelModules( qw( hid hid-bright unix vesafb fbcon ));
+
+ return;
+}
+
+sub determineMatchingHwinfoVersion
+{
+ my $self = shift;
+ my $distroVersion = shift;
+
+ my %versionMap = (
+ '10.2' => '13.11',
+ '10.3' => '14.19',
+ '11.0' => '15.3',
+ '11.1' => '15.21',
+ '11.2' => '16.0',
+ '11.3' => '16.0'
+ );
+ return $versionMap{$distroVersion}
+ || $self->SUPER::determineMatchingHwinfoVersion($distroVersion);
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm
new file mode 100644
index 00000000..2c59bbae
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu.pm
@@ -0,0 +1,73 @@
+ # Copyright (c) 2006..2010 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitRamFS::Distro::Ubuntu.pm
+# - provides Ubuntu-specific overrides of the MakeInitRamFS::Distro API.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Distro::Ubuntu;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Distro::Base);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'base-name' => 'ubuntu',
+ };
+ return bless $self, $class;
+}
+
+# filter out modules not present (e.g. because compiled into the kernel)
+sub applyChanges
+{
+ my $self = shift;
+ my $engine = shift;
+
+ #if ($engine->{'distro-name'} =~ m{-([^-]+)$}) {
+ # my $distroVersion = 0.0 + $1;
+ # if ($distroVersion <= 8.10) {
+ # $engine->_addFilteredKernelModules( qw( unix hid-bright ));
+ # }
+ # else {
+ # $engine->_addFilteredKernelModules( qw( unix hid-bright af_packet uhci-hcd ohci-hcd ));
+ # }
+ #}
+ $engine->_addFilteredKernelModules( qw( unix hid-bright af_packet uhci-hcd ohci-hcd ));
+
+ return;
+}
+
+sub determineMatchingHwinfoVersion
+{
+ my $self = shift;
+ my $distroVersion = shift;
+
+ # Please check, if correct
+ my %versionMap = (
+ '7.10' => '14.19',
+ '8.04' => '15.3',
+ '8.10' => '15.21',
+ '9.04' => '15.21',
+ '9.10' => '16.0',
+ '10.04' => '16.0',
+ );
+ return $versionMap{$distroVersion}
+ || $self->SUPER::determineMatchingHwinfoVersion($distroVersion);
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu_9.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu_9.pm
new file mode 100644
index 00000000..b0087253
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Distro/Ubuntu_9.pm
@@ -0,0 +1,38 @@
+# Copyright (c) 2009 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitRamFS::Distro::Ubuntu_9.pm
+# - provides Ubuntu-9.X-specific overrides of the MakeInitRamFS::Distro API.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Distro::Ubuntu_9;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Distro::Ubuntu);
+
+use OpenSLX::Basics;
+
+################################################################################
+### implementation
+################################################################################
+sub applyChanges
+{
+ my $self = shift;
+ my $engine = shift;
+
+ $engine->_addFilteredKernelModules(
+ qw( af_packet unix hid uhci-hcd ohci-hcd )
+ );
+
+ return;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
new file mode 100644
index 00000000..b09543dc
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
@@ -0,0 +1,453 @@
+# Copyright (c) 2006..2010 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitialRamFS::Engine::Base.pm
+# - provides basic driver engine for MakeInitialRamFS API.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Engine::Base;
+
+use strict;
+use warnings;
+use Switch;
+
+use File::Basename;
+use POSIX qw(strftime);
+
+use OpenSLX::Basics;
+use OpenSLX::LibScanner;
+use OpenSLX::OSPlugin::Roster;
+use OpenSLX::Utils;
+
+################################################################################
+### interface methods
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $params = shift || {};
+
+ checkParams($params, {
+ 'attrs' => '!',
+ 'debug-level' => '?',
+ 'export-name' => '!',
+ 'export-uri' => '!',
+ 'initramfs' => '!',
+ 'kernel-params' => '!',
+ 'kernel-version' => '!',
+ 'plugins' => '!',
+ 'root-path' => '!',
+ 'slx-version' => '!',
+ 'system-name' => '!',
+ 'preboot-id' => '?',
+ 'boot-uri' => '?',
+ } );
+
+ my $self = $params;
+
+ $self->{'system-name'} =~ m{^([^\-]+)-([^:\-]+)}
+ or die "unable to extract distro-info from $self->{'system-name'}!";
+
+ $self->{'distro-name'} = lc($1);
+ $self->{'distro-ver'} = $2;
+
+ my $fullDistroName = lc($1) . '-' . $2;
+
+ $self->{distro} = loadDistroModule({
+ distroName => $fullDistroName,
+ distroScope => 'OpenSLX::MakeInitRamFS::Distro',
+ });
+ if (!$self->{distro}) {
+ die _tr(
+ 'unable to load any MakeInitRamFS::Distro module for system %s!',
+ $self->{'system-name'}
+ );
+ }
+
+ $self->{'lib-scanner'}
+ = OpenSLX::LibScanner->new({ 'root-path' => $self->{'root-path'} });
+
+ $self->{'suggested-kernel-modules'} = [];
+ $self->{'filtered-kernel-modules'} = [];
+
+ return bless $self, $class;
+}
+
+sub execute
+{
+ my $self = shift;
+ my $dryRun = shift;
+
+ $self->_collectCMDs();
+
+ vlog(1, _tr("creating initramfs '%s' ...", $self->{'initramfs'}));
+ $self->_executeCMDs() unless $dryRun;
+
+ return;
+}
+
+sub haveKernelParam
+{
+ my $self = shift;
+ my $param = shift;
+
+ return ref $param eq 'Regexp'
+ ? grep { $_ =~ $param } @{ $self->{'kernel-params'} }
+ : grep { $_ eq $param } @{ $self->{'kernel-params'} };
+}
+
+sub addKernelParams
+{
+ my $self = shift;
+
+ push @{ $self->{'kernel-params'} }, @_;
+
+ return;
+}
+
+sub kernelParams
+{
+ my $self = shift;
+
+ return @{ $self->{'kernel-params'} };
+}
+
+sub addKernelModules
+{
+ my $self = shift;
+
+ push @{ $self->{'suggested-kernel-modules'} }, @_;
+
+ return;
+}
+
+################################################################################
+### implementation methods
+################################################################################
+sub _executeCMDs
+{
+ my $self = shift;
+
+ foreach my $cmd (@{$self->{CMDs}}) {
+ if (ref($cmd) eq 'HASH') {
+ vlog(3, "writing $cmd->{file}");
+ my $flags = defined $cmd->{mode} ? { mode => $cmd->{mode} } : undef;
+ spitFile($cmd->{file}, $cmd->{content}, $flags);
+ }
+ else {
+ vlog(3, "executing: $cmd");
+ if (slxsystem($cmd)) {
+ die _tr(
+ "unable to execute shell-cmd\n\t%s", $cmd
+ );
+ }
+ }
+ }
+
+ return;
+}
+
+sub addCMD
+{
+ my $self = shift;
+ my $cmd = shift;
+
+ push @{$self->{CMDs}}, $cmd;
+
+ return;
+}
+
+sub _findBinary
+{
+ my $self = shift;
+ my $binary = shift;
+
+ my @binDirs = qw(
+ bin sbin usr/bin usr/sbin usr/local/bin usr/local/sbin usr/bin/X11
+ );
+ foreach my $binDir (@binDirs) {
+ my $binPath = "$self->{'root-path'}/$binDir/$binary";
+ return $binPath if -f $binPath && -x $binPath;
+ }
+
+ return;
+}
+
+sub _addFilteredKernelModules
+{
+ my $self = shift;
+
+ push @{ $self->{'filtered-kernel-modules'} }, @_;
+
+ return;
+}
+
+sub _copyKernelModules
+{
+ my $self = shift;
+
+ # read modules.dep and use it to determine module dependencies
+ my $sourcePath = "$self->{'root-path'}/lib/modules/$self->{'kernel-version'}";
+ my @modulesDep = slurpFile("$sourcePath/modules.dep")
+ or die _tr('unable to open %s!', "$sourcePath/modules.dep");
+ my (%dependentModules, %modulePath, %modulesToBeCopied);
+ foreach my $modulesDep (@modulesDep) {
+ next if $modulesDep !~ m{^(.+?)/([^/]+)\.ko:\s*(.*?)\s*$};
+ my $path = $1;
+ if (substr($path, 0, 5) ne '/lib/') {
+ # some distros (e.g. ubuntu-9) use a local path instead of an
+ # absolute path, we need to make it absolute:
+ $path = "/lib/modules/$self->{'kernel-version'}/$path";
+ }
+ my $module = $2;
+ my $dependentsList = $3;
+ my $fullModulePath = "$path/$module.ko";
+ $modulePath{$module} = [] if !exists $modulePath{$module};
+ push @{$modulePath{$module}}, $fullModulePath;
+ $dependentModules{$fullModulePath} = [
+ map {
+ if (substr($_, 0, 5) ne '/lib/') {
+ # some distros (e.g. ubuntu-9) use a local path instead of an
+ # absolute path, we need to make it absolute:
+ $_ = "/lib/modules/$self->{'kernel-version'}/$_";
+ }
+ $_;
+ }
+ split ' ', $dependentsList
+ ];
+ }
+
+ my $targetPath
+ = "$self->{'build-path'}/lib/modules/$self->{'kernel-version'}";
+ $self->addCMD("mkdir -p $targetPath");
+ $self->addCMD("cp -p $sourcePath/modules.* $targetPath/");
+
+ # add a couple of kernel modules that we expect to be used in stage3
+ # (some of these modules do not exist on all distros, so they will be
+ # filtered out again by the respective distro object):
+ my @kernelModules = qw(
+ af_packet unix hid hid-bright usbhid uhci-hcd ohci-hcd vesafb fbcon
+ );
+ push @kernelModules, @{ $self->{'suggested-kernel-modules'} };
+
+ push @kernelModules, split ' ', $self->{attrs}->{ramfs_fsmods};
+ push @kernelModules, split ' ', $self->{attrs}->{ramfs_miscmods};
+ push @kernelModules, split ' ', $self->{attrs}->{ramfs_nicmods};
+
+ if ($self->{attrs}->{ramfs_nicmods} =~ m{virtio}i) {
+ push @kernelModules, qw( virtio_pci virtio_net );
+ }
+
+ # a function that determines dependent modules recursively
+ my $addDependentsSub;
+ $addDependentsSub = sub {
+ my $modulePath = shift;
+ foreach my $dependentModule (@{$dependentModules{$modulePath}}) {
+ next if $modulesToBeCopied{$dependentModule};
+ $modulesToBeCopied{$dependentModule} = 1;
+ $addDependentsSub->($dependentModule);
+ }
+ };
+
+ # start with the given kernel modules (names) and build a list of all
+ # required modules
+ foreach my $kernelModule (@kernelModules) {
+ if (!$modulePath{$kernelModule}) {
+ if (! grep { $_ eq $kernelModule }
+ @{ $self->{'filtered-kernel-modules'} }
+ ) {
+ warn _tr(
+ 'kernel module "%s" not found (in modules.dep)',
+ $kernelModule
+ );
+ }
+ }
+ foreach my $modulePath (@{$modulePath{$kernelModule}}) {
+ next if $modulesToBeCopied{$modulePath};
+ $modulesToBeCopied{$modulePath} = 1;
+ $addDependentsSub->($modulePath);
+ }
+ }
+
+ # build a list of required firmwares out of the list of modules - not
+ # totally optimal
+ my @firmwares;
+ $self->addCMD("mkdir -p $self->{'build-path'}/lib/firmware/$self->{'kernel-version'}");
+ foreach my $moduleToBeCopied(%modulesToBeCopied) {
+ $moduleToBeCopied =~ /.*\/(.*?)$/;
+ # implies usage of switch
+ vlog(1,$1);
+ switch ($1){
+ case "e100.ko" {push @firmwares, split ' ', "e100"}
+ case "iwlwifi" {
+ push @firmwares, split ' ',
+ "iwlwifi-3945-1.ucode iwlwifi-3945-2.ucode iwlwifi-4965-1.ucode iwlwifi-4965-2.ucode iwlwifi-5000-1.ucode"
+ }
+ case "tg3.ko" {push @firmwares, split ' ', "tigon/"}
+ # modules required for graphic adaptors (bootsplash, Xorg)
+ case "radeon.ko" {push @firmwares, split ' ', "radeon/"}
+ case "mga.ko" {push @firmwares, split ' ', "matrox/"}
+ case "r128.ko" {push @firmwares, split ' ', "r128/"}
+ }
+ }
+ # copy all the firmwares that we think are required
+ foreach my $firmwareToBeCopied (@firmwares) {
+ my $source = followLink(
+ "$self->{'root-path'}/lib/firmware/$self->{'kernel-version'}/$firmwareToBeCopied", $self->{'root-path'}
+ );
+ if (-e $source){
+ my $target = "$self->{'build-path'}/lib/firmware/";
+
+ $self->addCMD("cp -pr --dereference $source $target");
+ } else {
+ vlog(3,"unable to find $source for copying purposes");
+ }
+ }
+
+ # copy all the modules that we think are required
+ foreach my $moduleToBeCopied (sort keys %modulesToBeCopied) {
+ my $source = followLink(
+ "$self->{'root-path'}$moduleToBeCopied", $self->{'root-path'}
+ );
+ my $target = "$self->{'build-path'}$moduleToBeCopied";
+ my ($targetdir) = $target =~m/(.*\/).*$/;
+ vlog(5,"Trying to make directory: $targetdir");
+ $self->addCMD("mkdir -p $targetdir");
+ $self->addCMD("cp -p --dereference $source $target");
+ }
+
+ return;
+}
+
+sub _platformSpecificFileFor
+{
+ my $self = shift;
+ my $binary = shift;
+
+ if ($self->{'system-name'} =~ m{64}) {
+ return $binary . '.x86_64';
+ }
+ return $binary . '.i586';
+}
+
+sub _writeInitramfsSetup
+{
+ my $self = shift;
+
+ # generate initramfs-setup file containing attributes that are
+ # relevant for the initramfs only (before there's a root-FS):
+ my $initramfsAttrs = {
+ 'host_name' => 'slx-client', # just to have something at all
+ 'ramfs_fsmods' => $self->{attrs}->{ramfs_fsmods} || '',
+ 'ramfs_miscmods' => $self->{attrs}->{ramfs_miscmods} || '',
+ 'ramfs_nicmods' => $self->{attrs}->{ramfs_nicmods} || '',
+ 'ramfs_firmmods' => $self->{attrs}->{ramfs_firmmods} || '',
+ 'rootfs' => $self->{'export-uri'} || '',
+ 'hw_local_disk' => $self->{attrs}->{hw_local_disk} || '',
+ };
+ my $content = "# attributes set by slxconfig-demuxer:\n";
+ foreach my $attr (keys %$initramfsAttrs) {
+ $content .= qq[$attr="$initramfsAttrs->{$attr}"\n];
+ }
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/initramfs-setup",
+ content => $content
+ } );
+
+ return;
+}
+
+sub _writeSlxSystemConf
+{
+ my $self = shift;
+
+ # generate slxsystem.conf file with variables that are needed
+ # in stage3 init.
+ # TODO: either put this stuff into initramfs-setup or find another solution
+ my $date = strftime("%d.%m.%Y", localtime);
+ my $slxConf = unshiftHereDoc(<<" End-of-Here");
+ slxconf_date=$date
+ slxconf_kernver=$self->{'kernel-version'}
+ slxconf_listnwmod="$self->{attrs}->{ramfs_nicmods}"
+ slxconf_distro_name=$self->{'distro-name'}
+ slxconf_distro_ver=$self->{'distro-ver'}
+ slxconf_system_name=$self->{'system-name'}
+ slxconf_slxver="$self->{'slx-version'}"
+ End-of-Here
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/slxsystem.conf",
+ content => $slxConf
+ } );
+
+ # check if default directories available and copy them to /etc
+ my $defaultDirConfig = "$self->{'root-path'}/etc/opt/openslx/openslx.conf";
+ my $configTargetPath = "$self->{'build-path'}/etc";
+ #my $defaultConfVer = slurpFile("$defaultDirConfig");
+ #my $actConfVer = "Version 0.2";
+
+ if (-r $defaultDirConfig) {
+ $self->addCMD("cp -p $defaultDirConfig $configTargetPath/");
+# if ($defaultConfVer =~ m{$actConfVer}) {
+# warn _tr(
+# "Your version of default dir file (openslx.conf) is to old!\n".
+# "Eventually the system won't work.\n" .
+# "Please run install, update or clone of this system again!\n");
+# }
+ } else {
+ die _tr(
+ "No default directories defined!\n" .
+ "Please run install, update or clone of this system again!\n");
+ }
+
+ return;
+}
+
+sub _calloutToPlugins
+{
+ my $self = shift;
+
+ my $pluginInitdPath = "$self->{'build-path'}/etc/plugin-init.d";
+ my $initHooksPath = "$self->{'build-path'}/etc/init-hooks";
+ $self->addCMD("mkdir -p $pluginInitdPath $initHooksPath");
+
+ foreach my $pluginName (@{$self->{'plugins'}}) {
+ my $plugin = OpenSLX::OSPlugin::Roster->getPlugin($pluginName);
+ next if !$plugin;
+
+ # create a hash only containing the attributes relating to the
+ # current plugin
+ my $allAttrs = $self->{attrs};
+ my %pluginAttrs;
+ for my $attrName (grep { $_ =~ m{^${pluginName}::} } keys %$allAttrs) {
+ $pluginAttrs{$attrName} = $allAttrs->{$attrName};
+ }
+
+ # let plugin setup itself in the initramfs
+ $plugin->setupPluginInInitramfs(\%pluginAttrs, $self);
+ }
+ return;
+}
+
+sub _createInitRamFS
+{
+ my $self = shift;
+
+ my $buildPath = $self->{'build-path'};
+ $self->addCMD("chroot $buildPath ldconfig");
+ $self->addCMD(
+ "cd $buildPath "
+ . "&& find . "
+ . "| cpio -H newc --quiet --create "
+ . "| gzip -9 >$self->{initramfs}"
+ );
+
+ return;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Engine/PBS.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/PBS.pm
new file mode 100644
index 00000000..571057ad
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/PBS.pm
@@ -0,0 +1,42 @@
+# Copyright (c) 2009 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitialRamFS::Engine::PBS.pm
+# - provides driver engine for MakeInitialRamFS API, implementing the
+# base of all preboot variants.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Engine::PBS;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Engine::Preboot);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+sub _copyPrebootSpecificFiles
+{
+ my $self = shift;
+
+ # write secondary rootfs-layer (including init) on top of base layer
+ my $prebootRootfs
+ = "$openslxConfig{'base-path'}/share/boot-env/preboot/uclib-rootfs";
+ $self->addCMD("rsync -rlpt $prebootRootfs/ $self->{'build-path'}");
+
+ # overwrite preboot defaults
+ my $pbsRootfs
+ = "$openslxConfig{'base-path'}/share/boot-env/pbs/uclib-rootfs";
+ $self->addCMD("rsync -rlpt $pbsRootfs/ $self->{'build-path'}");
+
+ return 1;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm
new file mode 100644
index 00000000..aecfd00f
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm
@@ -0,0 +1,143 @@
+# Copyright (c) 2006-2008 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitialRamFS::Engine::Preboot.pm
+# - provides driver engine for MakeInitialRamFS API, implementing the
+# base of all preboot variants.
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Engine::Preboot;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Engine::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation methods
+################################################################################
+sub _collectCMDs
+{
+ my $self = shift;
+
+ $self->{CMDs} = [];
+
+ $self->_setupBuildPath();
+
+ $self->_writeInitramfsSetup();
+ $self->_writeSlxSystemConf();
+
+ $self->_copyUclibcRootfs();
+ $self->_copyPrebootSpecificFiles();
+
+ $self->{distro}->applyChanges($self);
+
+ $self->_copyKernelModules();
+
+ $self->_createInitRamFS();
+
+ return;
+}
+
+sub _setupBuildPath
+{
+ my $self = shift;
+
+ my $buildPath = "$openslxConfig{'temp-path'}/slx-initramfs";
+ $self->addCMD("rm -rf $buildPath");
+
+ my @stdFolders = qw(
+ bin
+ dev
+ etc
+ lib
+ mnt
+ proc
+ root
+ sbin
+ sys
+ tmp
+ var/lib
+ var/run
+ );
+ $self->addCMD(
+ 'mkdir -p ' . join(' ', map { "$buildPath/$_"; } @stdFolders)
+ );
+
+ $self->{'build-path'} = $buildPath;
+
+ return;
+}
+
+sub _writeInitramfsSetup
+{
+ my $self = shift;
+
+ # generate initramfs-setup file containing attributes that are
+ # relevant for the initramfs only (before there's a root-FS) -
+ # this override adds the name of the client such that the booting
+ # system has an ID to use for accessing the corresponding boot environment
+ # on the server
+ my $initramfsAttrs = {
+ 'host_name' => 'slx-client', # just to have something at all
+ 'ramfs_miscmods' => $self->{attrs}->{ramfs_miscmods} || '',
+ 'ramfs_nicmods' => $self->{attrs}->{ramfs_nicmods} || '',
+ 'ramfs_firmmods' => $self->{attrs}->{ramfs_firmmods} || '',
+ 'preboot_id' => $self->{'preboot-id'} || '',
+ 'boot_uri' => $self->{'boot-uri'} || '',
+ };
+ my $content = "# attributes set by slxconfig-demuxer:\n";
+ foreach my $attr (keys %$initramfsAttrs) {
+ $content .= qq[$attr="$initramfsAttrs->{$attr}"\n];
+ }
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/initramfs-setup",
+ content => $content
+ } );
+
+ return;
+}
+
+sub _copyUclibcRootfs
+{
+ my $self = shift;
+
+ my $uclibcRootfs = "$openslxConfig{'base-path'}/share/uclib-rootfs";
+
+ my @excludes = qw(
+ );
+
+ # exclude strace unless this system is in debug mode
+ if (!$self->{'debug-level'}) {
+ push @excludes, 'strace';
+ }
+
+ my $exclOpts = join ' ', map { "--exclude $_" } @excludes;
+
+ $self->addCMD("rsync $exclOpts -rlpt $uclibcRootfs/ $self->{'build-path'}");
+
+ return 1;
+}
+
+sub _copyPrebootSpecificFiles
+{
+ my $self = shift;
+
+ # write secondary rootfs-layer (including init) on top of base layer
+ my $prebootRootfs
+ = "$openslxConfig{'base-path'}/share/boot-env/preboot/uclib-rootfs";
+ $self->addCMD("rsync -rlpt $prebootRootfs/ $self->{'build-path'}");
+
+ return 1;
+}
+
+1;
diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm
new file mode 100644
index 00000000..1334c444
--- /dev/null
+++ b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm
@@ -0,0 +1,264 @@
+# Copyright (c) 2006-2008 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# MakeInitialRamFS::Engine::SlxBoot.pm
+# - provides driver engine for MakeInitialRamFS API, implementing the
+# standard slx boot behaviour (i.e. booting a system remotely).
+# -----------------------------------------------------------------------------
+package OpenSLX::MakeInitRamFS::Engine::SlxBoot;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::MakeInitRamFS::Engine::Base);
+
+use File::Find;
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation methods
+################################################################################
+sub _collectCMDs
+{
+ my $self = shift;
+
+ $self->{CMDs} = [];
+
+ $self->_setupBuildPath();
+
+ $self->_addRequiredFSMods();
+
+ $self->_writeInitramfsSetup();
+ $self->_writeSlxSystemConf();
+
+ $self->_copyUclibcRootfs();
+ $self->_copyHwinfo();
+ $self->_copyDistroSpecificFiles();
+ $self->_copyInitramfsFiles();
+
+ $self->_copyPreAndPostinitFiles();
+
+ $self->_calloutToPlugins();
+
+ $self->{distro}->applyChanges($self);
+
+ $self->_copyKernelModules();
+
+ $self->_createInitRamFS();
+
+ return;
+}
+
+sub _setupBuildPath
+{
+ my $self = shift;
+
+ my $buildPath = "$openslxConfig{'temp-path'}/slx-initramfs";
+ $self->addCMD("rm -rf $buildPath");
+
+ my @stdFolders = qw(
+ bin
+ dev
+ etc
+ etc/init-hooks
+ lib
+ mnt
+ proc
+ root
+ sbin
+ sys
+ tmp
+ usr/share
+ var/lib
+ var/lib/nfs/state
+ var/run
+ );
+ $self->addCMD(
+ 'mkdir -p ' . join(' ', map { "$buildPath/$_"; } @stdFolders)
+ );
+
+ $self->{'build-path'} = $buildPath;
+
+ return;
+}
+
+sub _copyDistroSpecificFiles
+{
+ my $self = shift;
+
+ my $distroSpecsPath = "$openslxConfig{'base-path'}/share/distro-specs";
+
+ my $distroName = $self->{'distro-name'};
+ my $distroVer = $self->{'distro-ver'};
+
+ # concatenate default- and distro-specific functions into one file
+ my $functions = slurpFile("$distroSpecsPath/$distroName/functions-default");
+ $functions .= "\n";
+ $functions .= slurpFile(
+ "$distroSpecsPath/$distroName/functions-$distroVer",
+ { failIfMissing => 0 }
+ );
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/distro-functions",
+ content => $functions,
+ } );
+
+ return 1;
+}
+
+sub _copyUclibcRootfs
+{
+ my $self = shift;
+
+ my $uclibcRootfs = "$openslxConfig{'base-path'}/share/uclib-rootfs";
+
+ my @excludes = qw(
+ dialog
+ kexec
+ libcurses.so*
+ libncurses.so*
+ mconf
+ );
+
+ # exclude strace unless this system is in debug mode
+ if (!$self->{'debug-level'}) {
+ push @excludes, 'strace';
+ }
+
+ my $exclOpts = join ' ', map { "--exclude $_" } @excludes;
+
+ $self->addCMD("rsync $exclOpts -rlpt $uclibcRootfs/ $self->{'build-path'}");
+
+ return 1;
+}
+
+sub _copyHwinfo
+{
+ my $self = shift;
+
+ my $baseDir = "$openslxConfig{'base-path'}/share/ramfstools/hwinfo";
+
+ my $version = $self->{distro}->determineMatchingHwinfoVersion(
+ $self->{'distro-ver'}
+ );
+
+ # copy db modifications
+ $self->addCMD("tar xfz $baseDir/db/hwinfo.db.tgz -C $self->{'build-path'}/");
+
+ $self->addCMD("cp $baseDir/bin/hwinfo-$version $self->{'build-path'}/usr/bin/hwinfo");
+ my $libHD = "libhd.so.$version";
+ $self->addCMD("cp $baseDir/lib/$libHD $self->{'build-path'}/usr/lib");
+ my $libName = $libHD;
+ while($libName =~ s{\.\d+$}{}g) {
+ $self->addCMD("ln -sf $libHD $self->{'build-path'}/usr/lib/$libName");
+ }
+
+ return 1;
+}
+
+sub _copyInitramfsFiles
+{
+ my $self = shift;
+
+ my $initramfsPath = "$openslxConfig{'base-path'}/share/initramfs";
+
+ find(
+ {
+ wanted => sub {
+ my $len = length($initramfsPath);
+ my $file = $File::Find::name;
+ my $relName = length($file) > $len ? substr($file, $len+1) : '';
+ if (-d) {
+ $self->addCMD("mkdir -p $self->{'build-path'}/$relName");
+ } elsif (-l $file) {
+ my $target = readlink $file;
+ $self->addCMD(
+ "ln -sf $target $self->{'build-path'}/$relName"
+ );
+ } elsif (qx{file $file} =~ m{ELF}) {
+ $self->addCMD(
+ "cp -p $file $self->{'build-path'}/$relName"
+ );
+ } else {
+ my $text = slurpFile($file, { 'io-layer' => 'bytes' } );
+
+ # replace macros
+ # TODO: find out what these mean and maybe find a
+ # different, better solution
+ my %macro = (
+ 'COMDIRINDXS' => '/tmp/scratch /var/lib/nobody',
+ # keep serverip as it is (it is handled by init itself)
+ 'serverip' => '@@@serverip@@@',
+ );
+ $text =~ s{\@\@\@([^\@]+)\@\@\@}{
+ if (!exists $macro{$1}) {
+ warn _tr(
+ 'unknown macro @@@%s@@@ found in %s',
+ $1, $File::Find::name
+ );
+ '';
+ } else {
+ $macro{$1};
+ }
+ }eogms;
+
+ # force shebang with ash (deprecated with new busybox)
+ #$text =~ s{\A#!\s*/bin/.+?$}{#!/bin/ash}ms;
+
+ $self->addCMD( {
+ file => "$self->{'build-path'}/$relName",
+ content => $text,
+ mode => (-x $file ? 0755 : undef),
+ } );
+ }
+ },
+ no_chdir => 1,
+ },
+ $initramfsPath
+ );
+
+ return;
+}
+
+sub _copyPreAndPostinitFiles
+{
+ my $self = shift;
+
+ foreach my $cfg (
+ 'default/initramfs/preinit.local',
+ "$self->{'system-name'}/initramfs/preinit.local",
+ 'default/initramfs/postinit.local',
+ "$self->{'system-name'}/initramfs/postinit.local"
+ ) {
+ my $cfgPath = "$openslxConfig{'private-path'}/config/$cfg";
+ next if !-f $cfgPath;
+ $self->addCMD("cp -p $cfgPath $self->{'build-path'}/bin/");
+ }
+ return;
+}
+
+sub _addRequiredFSMods
+{
+ my $self = shift;
+
+ my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine");
+ $osExportEngine->initializeFromExisting($self->{'export-name'});
+ my $fsMods = $self->{attrs}->{ramfs_fsmods} || '';
+ foreach my $fsMod ($osExportEngine->requiredFSMods()) {
+ $fsMods .= " $fsMod" if $fsMods !~ m{$fsMod};
+ }
+ $self->{attrs}->{ramfs_fsmods} = $fsMods;
+
+ return;
+}
+
+1;
diff --git a/src/boot-env/pbs/uclib-rootfs/bin/bbinit b/src/boot-env/pbs/uclib-rootfs/bin/bbinit
new file mode 100755
index 00000000..3fd67612
--- /dev/null
+++ b/src/boot-env/pbs/uclib-rootfs/bin/bbinit
@@ -0,0 +1,19 @@
+#!/bin/hush
+
+# create clean setup
+mkdir -p /etc/events.conf
+mkdir -p /etc/events.d
+rm /etc/events.d/*
+for f in $(ls -1 /etc/events)
+do
+ ln -sf /etc/events/$f /etc/events.d/$f
+done
+
+mkdir -p /tmp/event
+rm /tmp/event/*
+rm /tmp/events
+
+# start bbinit
+inotifyd /bin/handleEvents /tmp/event/:n &
+# initial call (executing all zero dependent scipts)
+handleEvents
diff --git a/src/boot-env/pbs/uclib-rootfs/bin/handleEvents b/src/boot-env/pbs/uclib-rootfs/bin/handleEvents
new file mode 100755
index 00000000..9bb78951
--- /dev/null
+++ b/src/boot-env/pbs/uclib-rootfs/bin/handleEvents
@@ -0,0 +1,38 @@
+#!/bin/hush
+
+# wait for lock
+while [ -f /tmp/bbinit.lock ]
+do
+ sleep 0.1
+done
+
+# lock eventhandler
+touch /tmp/bbinit.lock
+
+# source list of finished events
+[ -f /tmp/events ] && . /tmp/events
+
+# go through all unhandled events
+for f in $( ls -1 /etc/events.d/ )
+do
+ . /etc/events.d/$f
+
+ # check dependencies
+ eval dep=\$${f}_depends
+ havealldeps=1
+ for d in $dep
+ do
+ eval havedep=\$have${d}
+ [ "x$havedep" == "x1" ] || havealldeps=0
+ done
+
+ # if nothing is missing execute script
+ if [ "x$havealldeps" == "x1" ]; then
+ echo executing $f
+ /etc/bbinit.d/$f &
+ rm /etc/events.d/$f
+ fi
+done
+
+# unlock eventhandler
+rm /tmp/bbinit.lock
diff --git a/src/boot-env/pbs/uclib-rootfs/etc/bbinit.d/example b/src/boot-env/pbs/uclib-rootfs/etc/bbinit.d/example
new file mode 100755
index 00000000..122cf566
--- /dev/null
+++ b/src/boot-env/pbs/uclib-rootfs/etc/bbinit.d/example
@@ -0,0 +1,32 @@
+#!/bin/hush
+
+me=$(basename $0)
+
+# read event parameters
+. /etc/events/$me
+eval provides=\$${me}_provides
+
+# get config output of the dependencies
+eval dep=\$${me}_depends
+for d in $dep
+do
+ [ -f /etc/event.conf/$d ] && . /etc/event.conf/$d
+done
+
+# do some stuff
+echo "[$me] starting .."
+for i in 1 2 3 4 5 6
+do
+ echo "[$me] $i"
+ sleep 1
+done
+echo "[$me] finished .."
+
+# write configuration output
+value="test"
+echo "${provides}_someconfig=\"$value\"" >> /etc/event.conf/$provides
+
+# trigger eventhandler
+echo "have${provides}=1" >> /tmp/events
+touch /tmp/event/$me
+
diff --git a/src/boot-env/pbs/uclib-rootfs/etc/events/example b/src/boot-env/pbs/uclib-rootfs/etc/events/example
new file mode 100644
index 00000000..75768967
--- /dev/null
+++ b/src/boot-env/pbs/uclib-rootfs/etc/events/example
@@ -0,0 +1,2 @@
+example_depends=""
+example_provides="example"
diff --git a/src/boot-env/pbs/uclib-rootfs/init b/src/boot-env/pbs/uclib-rootfs/init
new file mode 100755
index 00000000..847cad87
--- /dev/null
+++ b/src/boot-env/pbs/uclib-rootfs/init
@@ -0,0 +1,234 @@
+#!/bin/ash
+# Copyright (c) 2008..2009 - 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 at http://openslx.org
+#
+# Main script for preboot initial ramfs - preloading environment for running
+# OpenSLX linux stateless clients version 5.
+
+fetchip () {
+# we expect to get an ip address within 10++ seconds
+( sleep 6 ; killall udhcpc >/dev/null 2>&1 ) &
+for i in 1 2 ; do
+ udhcpc -f -n -q $vci -s /usr/share/udhcpc/default.script -i $nwif 2>/dev/null
+ if grep "ip=" /tmp/ipstuff >/dev/null 2>&1 ; then
+ . /tmp/ipstuff
+ for ns in $dns ; do
+ echo "nameserver $ns" >>/etc/resolv.conf
+ done
+ # simply add a single dns server for passing via kernel cmdline to stage3
+ # (quickhack, just the last, list of dns might be better ...)
+ echo "dnssrv=$ns" >>/tmp/ipstuff
+ return
+ else
+ if [ $i -eq 1 ] ; then
+ sleep 1
+ else
+ dialog --msgbox "Did not get any proper IP configuration: Please check \
+that your Ethernet card is supported, the machine is connected to the network \
+and a DHCP server is answering your requests." 7 65
+ ash
+ echo "o" >/proc/sysrq-trigger
+ fi
+ fi
+done
+}
+
+#############################################################################
+# PreBoot init main part
+
+# device files get their own filesystem
+devdir="/dev"
+mount -n -t tmpfs -o 'size=25%,mode=0755' mdev ${devdir}
+mkdir -p /dev/pts
+mount -t devpts devpts /dev/pts
+echo /sbin/mdev > /proc/sys/kernel/hotplug
+cat > /etc/mdev.conf << "EOF"
+sda* 0:6 0660
+sdb* 0:6 0660
+sg* 0:6 0660
+hda* 0:6 0660
+hdb* 0:6 0660
+EOF
+
+mdev -s
+
+export DEBUGLEVEL=0
+
+# create basic device files an directories in dev
+for i in "/dev/mem c 1 1" "/dev/null c 1 3" "/dev/zero c 1 5" \
+ "/dev/urandom c 1 9" "/dev/kmsg c 1 11" "/dev/tty0 c 4 0" \
+ "/dev/tty1 c 4 1" "/dev/tty2 c 4 2" "/dev/tty3 c 4 3" \
+ "/dev/tty4 c 4 4" "/dev/tty5 c 4 5" "/dev/tty6 c 4 6" \
+ "/dev/tty7 c 4 7" "/dev/tty8 c 4 8" "/dev/tty9 c 4 9" \
+ "/dev/tty10 c 4 10" "/dev/tty c 5 0" "/dev/console c 5 1" \
+ "/dev/ptmx c 5 2" "/dev/psaux c 10 1" "/dev/agpgart c 10 175" \
+ "/dev/fb0 c 29 0" "/dev/bootsplash p" "/dev/xconsole p"; do
+ mknod $i
+done
+mkdir -p ${devdir}/pts ${devdir}/shm
+export PATH=/bin:/sbin:/usr/bin/:/usr/sbin
+
+# redirect kernel messages to tty10 instead of tty1
+getty -i -n -l /bin/cat 38400 tty10 &
+setlogcons 10
+
+# initramfs-setup configuration (common settings for all clients using a
+# certain InitRamFS generated by slxmkramfs/mkdxsinitrd)
+[ -f /etc/initramfs-setup ] && . /etc/initramfs-setup 2>/dev/null
+
+# set a default LAN interface, has to be modified for WLAN or on machines
+# with more than one ethernet card built in
+nwif="eth0"
+
+# mount the important standard directories
+[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc
+[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys
+
+# load framebuffer modules if needed
+for mod in vesafb fbcon; do
+ if [ x != x$(find /lib/modules -name ${mod}.ko) ]; then
+ modprobe $mod || \
+ dialog --infobox "Module $mod did not load for some reason." 3 65
+ usleep 1000
+ fi
+done
+
+# give startup information
+dialog --infobox "Starting OpenSLX preboot environment ..." 3 65
+
+# load usb keyboard and network adaptor modules
+for mod in ${ramfs_nicmods} af_packet unix hid hid-bright usbhid \
+ uhci-hcd ohci-hcd ; do
+ if [ x != x$(find /lib/modules -name ${mod}.ko) ]; then
+ modprobe $mod || \
+ dialog --infobox "Module $mod did not load for some reason." 3 65
+ usleep 10000
+ fi
+done
+
+# set the default for boot type and read kernel commandline (for this and
+# other options)
+export TYPE=fastboot
+read KCMDLINE </proc/cmdline
+# read the system wide machine-setup and then the kernel commandline
+for opts in ${KCMDLINE} ; do
+ case ${opts} in
+ debug)
+ DEBUGLEVEL=1;;
+ # ... or a specified debug level (will be passed to next stage)
+ debug=*)
+ DEBUGLEVEL=${opts#debug=};;
+ # WLAN ssid (most probably passed that way, unused yet ...)
+ ssid=*)
+ SSID=${opts#SSID=};;
+ # Boot type (fastboot)/directkiosk/cfgkiosk/slxconfig
+ type=*)
+ TYPE=${opts#type=};;
+ pbsId=*)
+ PBS_ID=${opts#pbsId=};;
+ esac
+done
+
+# start a watchdog to ensure an automated reboot or halt of the machine if the
+# preboot init does not succeed (e.g. missing kernel module/firmware for the
+# network adaptor)
+if [ "${DEBUGLEVEL}" -eq 0 ] ; then
+ cat<<EOF >/bin/watchdog
+#!/bin/ash
+echo \$$ > /tmp/watchdogpid
+[ ! -f /proc/version ] && mount -n -t proc proc /proc
+sleep 120 2>/dev/null
+echo "o" >/proc/sysrq-trigger
+EOF
+ chmod u+x /bin/watchdog
+ watchdog &
+else
+ getty -i -n -l /bin/ash 38400 tty2 &
+fi
+
+if [ -n "${SSID}" ] ; then
+ # WLAN setup will most probably change the network interface name stored in
+ # nwif (to wlan0 or something like that)
+ [ $DEBUGLEVEL -gt 0 ] && echo "set essid to ${essid}";
+ #value of essid unchecked yet
+ # load network adaptor modules
+ cd /lib/modules/$(ls /lib/modules/)/kernel/drivers/net/wireless
+ for mod in $(find . | grep .ko | sed 's,.*/\([^/]*\).ko,\1',); do
+ echo "Mod:";
+ echo $mod;
+ modprobe $mod || echo "module $mod did not load for some reason"
+ usleep 10000
+ done
+ cd /
+ wlanif=$(iwconfig 2>/dev/null|sed -n "/ESSID:/p"|sed "s/ .*//")
+ [ $DEBUGLEVEL -gt 0 ] && echo "wlancard recognized as ${wlanif}";
+ ip link set dev ${wlanif} up
+ if iwconfig ${wlanif} mode managed essid "${essid}"; then
+ nwif=${wlanif}
+ else
+ error " Unable to configure the WLAN interface."
+ fi
+ :
+else
+ # check here for the active Ethernet link
+ ip link show dev eth1 >/dev/null 2>&1 && \
+ dialog --msgbox "More than one network interface found. This could cause \
+some trouble as their activation and ordering depends on the module load \
+order ..." 7 65
+fi
+
+# set up loopback networking and power up ethernet
+ip link set dev lo up
+ip addr add 127.0.0.1/8 dev lo
+ip link set dev $nwif up || echo "I did not find any usable network adaptor."
+
+# run udhcpc and start a debug shell if no lease could be obtained
+mkdir -p /usr/share/udhcpc
+echo -e "#!/bin/ash\nunset infomsg HOME IFS mask lease interface DEBUGLEVEL \
+BOOT_IMAGE\nset >/tmp/ipstuff" >/usr/share/udhcpc/default.script
+chmod u+x /usr/share/udhcpc/default.script
+modprobe -q af_packet
+[ -n $vci ] && vci="-V $vci"
+fetchip
+ip addr add $ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//) dev $nwif
+ip route add default via $router
+
+# get the mac address of the boot network adaptor
+macaddr=$(ip link show dev $nwif 2>/dev/null | \
+ sed -n "/ether [0-9e-f]\{2\}:.*/p" | sed -e "s/.*ether //;s/ .*//")
+echo "macaddr=$macaddr" >>/etc/initramfs-setup
+
+# at this point a little selection script could be downloaded, which lets the
+# user choose what kind of SLX client he wants to get
+dialog --infobox "Fetching preboot interactive part and configuration from \
+the net ($boot_uri) ..." 4 65
+mkdir -p /preboot
+wget -q -O /preboot/preboot.init ${boot_uri}bootloader/env/getinit/formedia/$PBS_ID
+chmod u+x /preboot/preboot.init
+
+echo "pbs_id=$PBS_ID" >> /etc/pbs.conf
+
+# start a debug shell if needed, else set quiet kernel parameter
+if [ "${DEBUGLEVEL}" -gt 0 ] ; then
+ echo "Starting shell, leaving it would continue init."
+ /bin/ash
+else
+ # no debugging output for stage3 run
+ echo "quiet=quiet" >>/etc/initramfs-setup
+fi
+# run the preboot interactive part which finally will execute kexec
+cd /preboot
+exec ./preboot.init
+# we should never return from that one ...
+dialog --msgbox "The execution of the main preboot component failed. Please \
+check network access of your box. Is $boot_uri reachable!?" 6 65
+# ping -c 1 $boot_uri
+sleep 20 && echo "o" >/proc/sysrq-trigger
+
diff --git a/src/boot-env/pbs/uclib-rootfs/preboot/preboot-scripts/dialog.functions b/src/boot-env/pbs/uclib-rootfs/preboot/preboot-scripts/dialog.functions
new file mode 100644
index 00000000..7c6dd784
--- /dev/null
+++ b/src/boot-env/pbs/uclib-rootfs/preboot/preboot-scripts/dialog.functions
@@ -0,0 +1,105 @@
+# Copyright (c) 2009 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# dialog.functions
+# provides shell scripts for dialog handling
+# -----------------------------------------------------------------------------
+
+# set -x
+
+if [ "x" == "x$DIALOG_HEIGHT" ]; then
+ DIALOG_HEIGHT="10"
+fi
+
+if [ "x" == "x$DIALOG_WIDTH" ]; then
+ DIALOG_WIDTH="40"
+fi
+
+_ddownload_checkpercentage () {
+ local lf=$1
+ percentage=$(tail -n 5 $lf | sed 's/\.//g' | awk '{print $2}'| sed -n "s/%//p"| tail -n 1)
+ return $percentage
+}
+
+ddownload () {
+ local dl_url=$1
+ local dl_titel=$2
+ local dl_outfile=$3
+ local dl_logfile=$4
+
+ local dl_server=$(dirname $dl_url)
+ local dl_file=$(basename $dl_url)
+
+ local dl_count
+
+ if [ "x" == "x$dl_logfile" ]; then
+ dl_logfile="/tmp/logfile.$$"
+ fi
+
+ if [ "x" == "x$dl_outfile" ]; then
+ dl_outfile="$dl_file"
+ fi
+
+ if [ "x" == "x$dl_title" ]; then
+ dl_title="Downloading $dl_file .."
+ fi
+
+ if [ -f "$dl_logfile" ]; then
+ rm $dl_logfile
+ fi
+
+ # start wget in background
+ wget -v -b $dl_url -o "$dl_logfile" -O $dl_outfile
+
+ sleep 0.1;
+ _ddownload_checkpercentage "$dl_logfile"
+
+ dl_count=$?
+
+ while [ $dl_count -le 99 ];
+ do
+ echo $dl_count |dialog --gauge "$dl_title" $DIALOG_HEIGHT $DIALOG_WIDTH
+ sleep 0.5
+ _ddownload_checkpercentage "$dl_logfile"
+ dl_count=$?
+ done
+
+ local finished=0
+ while [ ! $finished ]; do
+ finished=$(tail -n 4 $dl_logfile | grep -c "$dl_file");
+ done
+
+ echo 100 | dialog --gauge "$dl_title" $DIALOG_HEIGHT $DIALOG_WIDTH;
+
+}
+
+
+
+menu_firststart () {
+ while [ "x$(cat result)" = "x" ] ; do
+ dialog --menu "OpenSLX" 30 60 22 \
+ 01 "Kiosk" \
+ 02 "Kiosk Setup" \
+ 03 "Custom System" \
+ 2>result
+ done
+}
+
+menu_oldconfig () {
+ oldconf=$1;
+ while [ "x$(cat result)" = "x" ] ; do
+ dialog --menu "OpenSLX" 30 60 22 \
+ 01 "Kiosk" \
+ 02 "Kiosk Setup" \
+ 03 "Custom System" \
+ 04 "Custom System"
+ 2>result
+ done
+}
diff --git a/src/boot-env/preboot/conf/apache-openslx-preboot.conf b/src/boot-env/preboot/conf/apache-openslx-preboot.conf
new file mode 100644
index 00000000..4eb58809
--- /dev/null
+++ b/src/boot-env/preboot/conf/apache-openslx-preboot.conf
@@ -0,0 +1,24 @@
+ ScriptAlias /openslx-preboot/cgi-bin/ "/opt/openslx/share/boot-env/preboot/http-server/"
+
+ Alias "/openslx-preboot/users/" "/srv/openslx/preboot-users/"
+ <Directory "/srv/openslx/preboot-users/">
+ Options -Indexes -ExecCGI FollowSymLinks MultiViews
+ AllowOverride None
+ Order allow,deny
+ allow from all
+ </Directory>
+
+ Alias /openslx-preboot/ "/srv/openslx/preboot/"
+ <Directory "/srv/openslx/preboot/">
+ Options -Indexes -ExecCGI FollowSymLinks MultiViews
+ AllowOverride None
+ Order allow,deny
+ allow from all
+ </Directory>
+
+ <Directory "/opt/openslx/share/boot-env/preboot/http-server/">
+ AllowOverride None
+ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
+ Order allow,deny
+ Allow from all
+ </Directory>
diff --git a/src/boot-env/preboot/http-server/user_settings.pl b/src/boot-env/preboot/http-server/user_settings.pl
new file mode 100755
index 00000000..6c135267
--- /dev/null
+++ b/src/boot-env/preboot/http-server/user_settings.pl
@@ -0,0 +1,97 @@
+#!/usr/bin/perl -w
+# Copyright (c) 2009 - 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 at http://openslx.org
+#
+# cgi-bin script that accepts user settings and stores them in a special
+# folder on the openslx server
+
+use strict;
+use warnings;
+
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
+use File::Path;
+
+# add openslx stuff to @INC
+use FindBin;
+use lib "$FindBin::RealBin/../../../../lib";
+use lib "$FindBin::RealBin";
+
+# read default config
+use OpenSLX::Basics;
+openslxInit();
+
+# die "*** Taint mode must be active! ***" unless ${^TAINT};
+
+my $cgi = CGI->new;
+
+my $system = $cgi->param('system') || '';
+my $client = $cgi->param('client') || '';
+my $prebootID = $cgi->param('preboot_id') || '';
+my $type = $cgi->param('type') || 'directkiosk';
+my $errormsg = 'None';
+
+die "must give 'system' ($system), 'client' ($client) and 'preboot_id' ($prebootID)!\n"
+ unless $system && $client && $prebootID;
+
+my $webPath = "$openslxConfig{'public-path'}/preboot";
+my $src = "$webPath/client-config/$system/$prebootID.tgz";
+my $destPath = "$webPath/$prebootID/client-config/$system";
+
+# if fastboot (default) is selected and a ConfTGZ exist just proceed ...
+if ($type eq "fastboot" && !-e "$destPath/$client.tgz") { $type = "slxconfig"; }
+# directkiosk/cfgkiosk/slxconfig
+if ($type ne "fastboot") {
+ mkpath($destPath."/".$client);
+ system(qq{tar -xzf $src -C $destPath/$client/});
+
+
+ # from here on the modifications of client configuration should take place
+ # within $destPath/$client directory
+ if ($type eq "slxconfig") {
+ # configuration of a WAN boot SLX client
+ print STDERR "slxconfig sub";
+ }
+ elsif ($type eq "cfgkiosk") {
+ # configuration of a WAN boot SLX kiosk
+ }
+ elsif (!$type || $type eq "directkiosk") {
+ # deactivate the desktop plugin for the kiosk mode
+ open (CFGFILE, ">>$destPath/$client/initramfs/plugin-conf/desktop.conf");
+ print CFGFILE 'desktop_active="0"';
+ close (CFGFILE);
+ # activate the kiosk plugin
+ if (!-e "$destPath/$client/initramfs/plugin-conf/kiosk.conf") {
+ $errormsg = "The kiosk plugin seems not to be installed";
+ print STDERR $errormsg;
+ } else {
+ open (CFGFILE, ">>$destPath/$client/initramfs/plugin-conf/kiosk.conf");
+ print CFGFILE 'kiosk_active="1"';
+ close (CFGFILE);
+ }
+ }
+ else {
+ # unknown type
+ $errormsg = "You have passed an unknown boot type $type";
+ print STDERR $errormsg;
+ }
+ system(qq{cd $destPath/$client; tar -czf $destPath/$client.tgz *});
+ rmtree($destPath."/".$client);
+}
+
+# resulting page is not shown to the user (error reporting that way, or
+# completely empty reply?)
+print
+ $cgi->header(-charset => 'iso8859-1'),
+ $cgi->start_html('...');
+if ($errormsg) { print $cgi->p("Error: $errormsg"); }
+print
+ $cgi->end_html();
+
diff --git a/src/boot-env/preboot/http-server/users.pl b/src/boot-env/preboot/http-server/users.pl
new file mode 100755
index 00000000..cde3d227
--- /dev/null
+++ b/src/boot-env/preboot/http-server/users.pl
@@ -0,0 +1,90 @@
+#!/usr/bin/perl -w
+# Copyright (c) 2009 - 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 at http://openslx.org
+#
+# cgi-bin script that accepts user settings and stores them in a special
+# folder on the openslx server
+
+use strict;
+use warnings;
+
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
+use File::Path;
+use Switch;
+
+# add openslx stuff to @INC
+use FindBin;
+use lib "$FindBin::RealBin/../../../../lib";
+use lib "$FindBin::RealBin";
+
+# read default config
+use OpenSLX::Basics;
+openslxInit();
+
+my $cgi = CGI->new;
+my $mac = $cgi->param('user') || '';
+my $action = $cgi->param('action');
+my $data = $cgi->param('data');
+
+# global requirements
+die "must give 'mac' ($mac)!\n"
+ unless $mac;
+
+my $webPath = "$openslxConfig{'public-path'}/preboot-users";
+my $userConfFile = "$webPath/$mac.conf";
+
+# makes only sense if public path is writeable for www-data
+# otherwise you have to create directory manualy
+if ( ! -e $webPath ) {
+ mkpath ($webPath) or die _tr("Can't create user config directory (%s). Reason: %s", $webPath, @_);
+}
+
+my $output = "";
+my $error;
+
+switch ($action) {
+ case 'set' {
+ if ($data) {
+ open (MYFILE, ">$userConfFile");
+ print MYFILE $data;
+ close (MYFILE);
+ } else {
+ $error = "no data";
+ }
+ }
+ case 'read' {
+ if ( -e $userConfFile ) {
+ open (MYFILE, $userConfFile);
+ while (<MYFILE>) {
+ chomp;
+ $output .= "$_\n";
+ }
+ close (MYFILE);
+ } else {
+ $error = "foobar";
+ }
+
+ }
+ else {
+ #default case check if we have a user config
+ if ( -e $userConfFile ) { $output = "1"; }
+ else { $output = "0"; };
+ }
+}
+
+print $cgi->header('Content-type: text/plain');
+if ($error) {
+ print $error;
+} else {
+ print $output;
+}
+
+exit 0;
diff --git a/src/boot-env/preboot/preboot-scripts/dialog.functions b/src/boot-env/preboot/preboot-scripts/dialog.functions
new file mode 100644
index 00000000..7c6dd784
--- /dev/null
+++ b/src/boot-env/preboot/preboot-scripts/dialog.functions
@@ -0,0 +1,105 @@
+# Copyright (c) 2009 - 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 suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# dialog.functions
+# provides shell scripts for dialog handling
+# -----------------------------------------------------------------------------
+
+# set -x
+
+if [ "x" == "x$DIALOG_HEIGHT" ]; then
+ DIALOG_HEIGHT="10"
+fi
+
+if [ "x" == "x$DIALOG_WIDTH" ]; then
+ DIALOG_WIDTH="40"
+fi
+
+_ddownload_checkpercentage () {
+ local lf=$1
+ percentage=$(tail -n 5 $lf | sed 's/\.//g' | awk '{print $2}'| sed -n "s/%//p"| tail -n 1)
+ return $percentage
+}
+
+ddownload () {
+ local dl_url=$1
+ local dl_titel=$2
+ local dl_outfile=$3
+ local dl_logfile=$4
+
+ local dl_server=$(dirname $dl_url)
+ local dl_file=$(basename $dl_url)
+
+ local dl_count
+
+ if [ "x" == "x$dl_logfile" ]; then
+ dl_logfile="/tmp/logfile.$$"
+ fi
+
+ if [ "x" == "x$dl_outfile" ]; then
+ dl_outfile="$dl_file"
+ fi
+
+ if [ "x" == "x$dl_title" ]; then
+ dl_title="Downloading $dl_file .."
+ fi
+
+ if [ -f "$dl_logfile" ]; then
+ rm $dl_logfile
+ fi
+
+ # start wget in background
+ wget -v -b $dl_url -o "$dl_logfile" -O $dl_outfile
+
+ sleep 0.1;
+ _ddownload_checkpercentage "$dl_logfile"
+
+ dl_count=$?
+
+ while [ $dl_count -le 99 ];
+ do
+ echo $dl_count |dialog --gauge "$dl_title" $DIALOG_HEIGHT $DIALOG_WIDTH
+ sleep 0.5
+ _ddownload_checkpercentage "$dl_logfile"
+ dl_count=$?
+ done
+
+ local finished=0
+ while [ ! $finished ]; do
+ finished=$(tail -n 4 $dl_logfile | grep -c "$dl_file");
+ done
+
+ echo 100 | dialog --gauge "$dl_title" $DIALOG_HEIGHT $DIALOG_WIDTH;
+
+}
+
+
+
+menu_firststart () {
+ while [ "x$(cat result)" = "x" ] ; do
+ dialog --menu "OpenSLX" 30 60 22 \
+ 01 "Kiosk" \
+ 02 "Kiosk Setup" \
+ 03 "Custom System" \
+ 2>result
+ done
+}
+
+menu_oldconfig () {
+ oldconf=$1;
+ while [ "x$(cat result)" = "x" ] ; do
+ dialog --menu "OpenSLX" 30 60 22 \
+ 01 "Kiosk" \
+ 02 "Kiosk Setup" \
+ 03 "Custom System" \
+ 04 "Custom System"
+ 2>result
+ done
+}
diff --git a/src/boot-env/preboot/preboot.sh b/src/boot-env/preboot/preboot.sh
new file mode 100755
index 00000000..703af974
--- /dev/null
+++ b/src/boot-env/preboot/preboot.sh
@@ -0,0 +1,95 @@
+#!/bin/ash
+# Copyright (c) 2009 - 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 at http://openslx.org
+#
+# preboot script for user interaction with OpenSLX preloading environment for
+# Linux stateless clients (fetched by Preboot init over the net)
+
+# get configuration
+. /etc/initramfs-setup
+. ./preboot-scripts/dialog.functions
+
+# bring the mac address into the standard format 01-<MAC>
+client=$(echo 01-$macaddr|sed "s/:/-/g")
+
+# check if already a configuration is available to decide if user interaction
+# is required (path is to be fixed)
+wget -q -O /tmp/have-user-config "$boot_uri/users.pl?user=${client}"
+have_user_config=$(cat /tmp/have-user-config);
+
+if [ "x1" == "x$have_user_config" ]; then
+ wget -q -O /tmp/oldconfig "$boot_uri/users.pl?user=${client}&action=read"
+ . /tmp/oldconfig
+ menu_oldconfig $oldconfig
+else
+ menu_firststart
+fi
+rm result;
+
+# Switch here for several boot TYPE=fastboot/directkiosk/cfgkiosk/slxconfig
+# fastboot - no interaction use system from client config
+# directkiosk - start the default slx system into kiosk (using vmchooser)
+# cfgkiosk - offer the user changes to his kiosk system (GUI environment)
+# slxconfig - offer the user set of configuration options, like setting a non-
+# priviledged user, root password, standard gui, plugins to activate ...
+
+# we expect to have a system selection dialog file in /preboot/bootmenu.dialog
+while [ "x$(cat result)" = "x" ] ; do
+ dialog --file bootmenu.dialog 2>result
+done
+# source the system to boot configuration ($kernel, $initramfs, $append,
+# $label)
+sysname=$(cat result)
+. ./$sysname
+sysname=$(readlink $sysname)
+
+# set basic post data information
+postdata="system=${sysname}&preboot_id=${preboot_id}&client=${client}"
+
+# ask for desired debug level in stage3 if debug!=0 in preboot
+echo "0" >result
+[ x$DEBUGLEVEL != x0 ] && dialog --no-cancel --menu "Choose Debug Level:" \
+ 20 65 10 "0" "no debug output (splash)" \
+ "2" "standard debug output" \
+ "3" "debug output and shell" 2>result
+
+# change debug level here if required (adjusted for the rest of the interactive
+# part)
+DEBUGLEVEL=$(cat result)
+if [ x$DEBUGLEVEL != x0 ]; then
+ debug="debug=$DEBUGLEVEL"
+else
+ debug=""
+fi
+
+# send information to configuration host via http
+wget --post-data "$postdata" -O /tmp/cfg-error \
+ $boot_uri/cgi-bin/user_settings.pl
+
+[ "x$DEBUGLEVEL" != x0 -a grep -qe "Error:" /tmp/cfg-error 2>/dev/null ] && \
+ dialog --msgbox "An error occured ..." # to be elaborated
+
+# fetch kernel and initramfs of selected system
+dialog --infobox "Loading kernel of ${sysname} ..." 3 65
+wget -q -O /tmp/kernel $boot_uri/$kernel
+dialog --infobox "Loading initial ramfs of ${sysname} ..." 3 65
+wget -q -O /tmp/initramfs $boot_uri/$initramfs
+
+# read primary IP configuration to pass it on (behaviour like IPAPPEND=1 of
+# PXElinux)
+. /tmp/ipstuff
+
+[ "x$DEBUGLEVEL" != x0 ] && { clear; ash; }
+
+# start the new kernel with initialramfs and composed cmdline
+dialog --infobox "Booting OpenSLX client $label ..." 3 65
+kexec -l /tmp/kernel --initrd=/tmp/initramfs \
+ --append="$append file=$boot_uri/${preboot_id}/client-config/${sysname}/${client}.tgz $quiet ip=$ip:$siaddr:$router:$subnet:$dnssrv $debug" 2>/dev/null
+kexec -e >/dev/null 2>&1
diff --git a/src/boot-env/preboot/uclib-rootfs/init b/src/boot-env/preboot/uclib-rootfs/init
new file mode 100755
index 00000000..ab2f9ca0
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/init
@@ -0,0 +1,216 @@
+#!/bin/ash
+# Copyright (c) 2008..2009 - 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 at http://openslx.org
+#
+# Main script for preboot initial ramfs - preloading environment for running
+# OpenSLX linux stateless clients version 5.
+
+fetchip () {
+# we expect to get an ip address within 10++ seconds
+( sleep 10 ; killall udhcpc >/dev/null 2>&1 ) &
+for i in 1 2 ; do
+ udhcpc -f -n -q $vci -s /usr/share/udhcpc/default.script -i $nwif 2>/dev/null
+ if grep "ip=" /tmp/ipstuff >/dev/null 2>&1 ; then
+ . /tmp/ipstuff
+ for ns in $dns ; do
+ echo "nameserver $ns" >>/etc/resolv.conf
+ done
+ # simply add a single dns server for passing via kernel cmdline to stage3
+ # (quickhack, just the last, list of dns might be better ...)
+ echo "dnssrv=$ns" >>/tmp/ipstuff
+ return
+ else
+ if [ $i -eq 1 ] ; then
+ sleep 1
+ else
+ dialog --msgbox "Did not get any proper IP configuration: Please check \
+that your Ethernet card is supported, the machine is connected to the network \
+and a DHCP server is answering your requests." 7 65
+ ash
+ echo "o" >/proc/sysrq-trigger
+ fi
+ fi
+done
+}
+
+#############################################################################
+# PreBoot init main part
+
+# device files get their own filesystem
+devdir="/dev"
+mount -n -t tmpfs -o 'size=25%,mode=0755' initramfsdevs ${devdir}
+export DEBUGLEVEL=0
+
+# create basic device files an directories in dev
+for i in "/dev/mem c 1 1" "/dev/null c 1 3" "/dev/zero c 1 5" \
+ "/dev/urandom c 1 9" "/dev/kmsg c 1 11" "/dev/tty0 c 4 0" \
+ "/dev/tty1 c 4 1" "/dev/tty2 c 4 2" "/dev/tty3 c 4 3" \
+ "/dev/tty4 c 4 4" "/dev/tty5 c 4 5" "/dev/tty6 c 4 6" \
+ "/dev/tty7 c 4 7" "/dev/tty8 c 4 8" "/dev/tty9 c 4 9" \
+ "/dev/tty10 c 4 10" "/dev/tty c 5 0" "/dev/console c 5 1" \
+ "/dev/ptmx c 5 2" "/dev/psaux c 10 1" "/dev/agpgart c 10 175" \
+ "/dev/fb0 c 29 0" "/dev/bootsplash p" "/dev/xconsole p"; do
+ mknod $i
+done
+mkdir -p ${devdir}/pts ${devdir}/shm
+export PATH=/bin:/sbin:/usr/bin/:/usr/sbin
+
+# redirect kernel messages to tty10 instead of tty1
+getty -i -n -l /bin/cat 38400 tty10 &
+setlogcons 10
+
+# initramfs-setup configuration (common settings for all clients using a
+# certain InitRamFS generated by slxmkramfs/mkdxsinitrd)
+[ -f /etc/initramfs-setup ] && . /etc/initramfs-setup 2>/dev/null
+
+# set a default LAN interface, has to be modified for WLAN or on machines
+# with more than one ethernet card built in
+nwif="eth0"
+
+# mount the important standard directories
+[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc
+[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys
+
+# load framebuffer modules if needed
+for mod in vesafb fbcon; do
+ if [ x != x$(find /lib/modules -name ${mod}.ko) ]; then
+ modprobe $mod || \
+ dialog --infobox "Module $mod did not load for some reason." 3 65
+ usleep 1000
+ fi
+done
+
+# give startup information
+dialog --infobox "Starting OpenSLX preboot environment ..." 3 65
+
+# load usb keyboard and network adaptor modules
+for mod in ${ramfs_nicmods} af_packet unix hid hid-bright usbhid \
+ uhci-hcd ohci-hcd ; do
+ if [ x != x$(find /lib/modules -name ${mod}.ko) ]; then
+ modprobe $mod || \
+ dialog --infobox "Module $mod did not load for some reason." 3 65
+ usleep 10000
+ fi
+done
+
+# set the default for boot type and read kernel commandline (for this and
+# other options)
+export TYPE=fastboot
+read KCMDLINE </proc/cmdline
+# read the system wide machine-setup and then the kernel commandline
+for opts in ${KCMDLINE} ; do
+ case ${opts} in
+ debug)
+ DEBUGLEVEL=1;;
+ # ... or a specified debug level (will be passed to next stage)
+ debug=*)
+ DEBUGLEVEL=${opts#debug=};;
+ # WLAN ssid (most probably passed that way, unused yet ...)
+ ssid=*)
+ SSID=${opts#SSID=};;
+ # Boot type (fastboot)/directkiosk/cfgkiosk/slxconfig
+ type=*)
+ TYPE=${opts#type=};;
+ esac
+done
+
+# start a watchdog to ensure an automated reboot or halt of the machine if the
+# preboot init does not succeed (e.g. missing kernel module/firmware for the
+# network adaptor)
+if [ "${DEBUGLEVEL}" -eq 0 ] ; then
+ cat<<EOF >/bin/watchdog
+#!/bin/ash
+echo \$$ > /tmp/watchdogpid
+[ ! -f /proc/version ] && mount -n -t proc proc /proc
+sleep 120 2>/dev/null
+echo "o" >/proc/sysrq-trigger
+EOF
+ chmod u+x /bin/watchdog
+ watchdog &
+else
+ getty -i -n -l /bin/ash 38400 tty2 &
+fi
+
+if [ -n "${SSID}" ] ; then
+ # WLAN setup will most probably change the network interface name stored in
+ # nwif (to wlan0 or something like that)
+ [ $DEBUGLEVEL -gt 0 ] && echo "set essid to ${essid}";
+ #value of essid unchecked yet
+ # load network adaptor modules
+ cd /lib/modules/$(ls /lib/modules/)/kernel/drivers/net/wireless
+ for mod in $(find . | grep .ko | sed 's,.*/\([^/]*\).ko,\1',); do
+ echo "Mod:";
+ echo $mod;
+ modprobe $mod || echo "module $mod did not load for some reason"
+ usleep 10000
+ done
+ cd /
+ wlanif=$(iwconfig 2>/dev/null|sed -n "/ESSID:/p"|sed "s/ .*//")
+ [ $DEBUGLEVEL -gt 0 ] && echo "wlancard recognized as ${wlanif}";
+ ip link set dev ${wlanif} up
+ if iwconfig ${wlanif} mode managed essid "${essid}"; then
+ nwif=${wlanif}
+ else
+ error " Unable to configure the WLAN interface."
+ fi
+ :
+else
+ # check here for the active Ethernet link
+ ip link show dev eth1 >/dev/null 2>&1 && \
+ dialog --msgbox "More than one network interface found. This could cause \
+some trouble as their activation and ordering depends on the module load \
+order ..." 7 65
+fi
+
+# set up loopback networking and power up ethernet
+ip link set dev lo up
+ip addr add 127.0.0.1/8 dev lo
+ip link set dev $nwif up || echo "I did not find any usable network adaptor."
+
+# run udhcpc and start a debug shell if no lease could be obtained
+mkdir -p /usr/share/udhcpc
+echo -e "#!/bin/ash\nunset infomsg HOME IFS mask lease interface DEBUGLEVEL \
+BOOT_IMAGE\nset >/tmp/ipstuff" >/usr/share/udhcpc/default.script
+chmod u+x /usr/share/udhcpc/default.script
+modprobe -q af_packet
+[ -n $vci ] && vci="-V $vci"
+fetchip
+ip addr add $ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//) dev $nwif
+ip route add default via $router
+
+# get the mac address of the boot network adaptor
+macaddr=$(ip link show dev $nwif 2>/dev/null | \
+ sed -n "/ether [0-9e-f]\{2\}:.*/p" | sed -e "s/.*ether //;s/ .*//")
+echo "macaddr=$macaddr" >>/etc/initramfs-setup
+
+# at this point a little selection script could be downloaded, which lets the
+# user choose what kind of SLX client he wants to get
+dialog --infobox "Fetching preboot interactive part and configuration from \
+the net ($boot_uri) ..." 4 65
+wget -q -O /tmp/preboot.env $boot_uri/bootloader/${preboot_id}.env
+mkdir /preboot
+tar -xzf /tmp/preboot.env -C /preboot
+# start a debug shell if needed, else set quiet kernel parameter
+if [ "${DEBUGLEVEL}" -gt 0 ] ; then
+ echo "Starting shell, leaving it would continue init."
+ /bin/ash
+else
+ # no debugging output for stage3 run
+ echo "quiet=quiet" >>/etc/initramfs-setup
+fi
+# run the preboot interactive part which finally will execute kexec
+cd /preboot
+exec ./preboot.sh
+# we should never return from that one ...
+dialog --msgbox "The execution of the main preboot component failed. Please \
+check network access of your box. Is $boot_uri reachable!?" 6 65
+# ping -c 1 $boot_uri
+sleep 20 && echo "o" >/proc/sysrq-trigger
+
diff --git a/src/boot-env/preboot/uclib-rootfs/lib/libcurses.so b/src/boot-env/preboot/uclib-rootfs/lib/libcurses.so
new file mode 120000
index 00000000..c7b1e02a
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/lib/libcurses.so
@@ -0,0 +1 @@
+libncurses.so.5.6 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so b/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so
new file mode 120000
index 00000000..7257b6af
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so
@@ -0,0 +1 @@
+libncurses.so.5 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so.5 b/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so.5
new file mode 120000
index 00000000..c7b1e02a
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so.5
@@ -0,0 +1 @@
+libncurses.so.5.6 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so.5.6 b/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so.5.6
new file mode 100755
index 00000000..a395c6b7
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/lib/libncurses.so.5.6
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/bin/clear b/src/boot-env/preboot/uclib-rootfs/usr/bin/clear
new file mode 100755
index 00000000..acc13246
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/bin/clear
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/bin/dialog b/src/boot-env/preboot/uclib-rootfs/usr/bin/dialog
new file mode 100755
index 00000000..6929569f
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/bin/dialog
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/bin/w3m b/src/boot-env/preboot/uclib-rootfs/usr/bin/w3m
new file mode 100755
index 00000000..2766a681
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/bin/w3m
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so b/src/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so
new file mode 120000
index 00000000..cda623f3
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so
@@ -0,0 +1 @@
+libcrypto.so.0.9.8 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so.0.9.8 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so.0.9.8
new file mode 100755
index 00000000..bb1b8163
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libcrypto.so.0.9.8
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libcurses.so b/src/boot-env/preboot/uclib-rootfs/usr/lib/libcurses.so
new file mode 100755
index 00000000..32ad8efe
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libcurses.so
@@ -0,0 +1,11 @@
+/* GNU ld script
+ Since Gentoo has critical dynamic libraries in /lib, and the static versions
+ in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
+ run into linking problems. This "fake" dynamic lib is a linker script that
+ redirects the linker to the real lib. And yes, this works in the cross-
+ compiling scenario as the sysroot-ed linker will prepend the real path.
+
+ See bug http://bugs.gentoo.org/4411 for more info.
+ */
+OUTPUT_FORMAT ( elf32-i386 )
+GROUP ( /lib/libcurses.so )
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so b/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so
new file mode 120000
index 00000000..10e91696
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so
@@ -0,0 +1 @@
+libform.so.5 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.5 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.5
new file mode 120000
index 00000000..4a80f6b6
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.5
@@ -0,0 +1 @@
+libform.so.5.6 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.5.6 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.5.6
new file mode 100755
index 00000000..888adb22
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libform.so.5.6
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so b/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so
new file mode 120000
index 00000000..b12b5cfb
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so
@@ -0,0 +1 @@
+libmenu.so.5 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.5 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.5
new file mode 120000
index 00000000..869f4a57
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.5
@@ -0,0 +1 @@
+libmenu.so.5.6 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.5.6 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.5.6
new file mode 100755
index 00000000..fb190a90
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libmenu.so.5.6
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libncurses.so b/src/boot-env/preboot/uclib-rootfs/usr/lib/libncurses.so
new file mode 100755
index 00000000..e7122a85
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libncurses.so
@@ -0,0 +1,11 @@
+/* GNU ld script
+ Since Gentoo has critical dynamic libraries in /lib, and the static versions
+ in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
+ run into linking problems. This "fake" dynamic lib is a linker script that
+ redirects the linker to the real lib. And yes, this works in the cross-
+ compiling scenario as the sysroot-ed linker will prepend the real path.
+
+ See bug http://bugs.gentoo.org/4411 for more info.
+ */
+OUTPUT_FORMAT ( elf32-i386 )
+GROUP ( /lib/libncurses.so )
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so b/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so
new file mode 120000
index 00000000..b5cd4a70
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so
@@ -0,0 +1 @@
+libpanel.so.5 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.5 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.5
new file mode 120000
index 00000000..ff2e80a5
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.5
@@ -0,0 +1 @@
+libpanel.so.5.6 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.5.6 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.5.6
new file mode 100755
index 00000000..4acbc076
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libpanel.so.5.6
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so b/src/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so
new file mode 120000
index 00000000..7874414f
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so
@@ -0,0 +1 @@
+libssl.so.0.9.8 \ No newline at end of file
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so.0.9.8 b/src/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so.0.9.8
new file mode 100755
index 00000000..194078c5
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/lib/libssl.so.0.9.8
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/sbin/kdump b/src/boot-env/preboot/uclib-rootfs/usr/sbin/kdump
new file mode 100755
index 00000000..07226a4b
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/sbin/kdump
Binary files differ
diff --git a/src/boot-env/preboot/uclib-rootfs/usr/sbin/kexec b/src/boot-env/preboot/uclib-rootfs/usr/sbin/kexec
new file mode 100755
index 00000000..cc49c45c
--- /dev/null
+++ b/src/boot-env/preboot/uclib-rootfs/usr/sbin/kexec
Binary files differ
diff --git a/src/boot-env/syslinux/LICENSE b/src/boot-env/syslinux/LICENSE
new file mode 100644
index 00000000..7233bc7e
--- /dev/null
+++ b/src/boot-env/syslinux/LICENSE
@@ -0,0 +1,3 @@
+This package is free software distributed under the GPL version 2.
+See http://openslx.org/COPYING. For additional information on the
+SYSLINUX component by H.P. Anwin check http://syslinux.zytor.com!
diff --git a/src/boot-env/syslinux/README.iso b/src/boot-env/syslinux/README.iso
new file mode 100644
index 00000000..f9abdbea
--- /dev/null
+++ b/src/boot-env/syslinux/README.iso
@@ -0,0 +1,6 @@
+You seem to have the OpenSLX network demo CD/DVD still in your optical
+drive! This is not required. You may safely remove the medium just
+after the first kernel/initramfs is loaded ...
+
+If you have any feedback please consult http://openslx.org/feedback
+and send your comments to feedback@openslx.org!
diff --git a/src/boot-env/syslinux/README.pxe b/src/boot-env/syslinux/README.pxe
new file mode 100644
index 00000000..9a14ee52
--- /dev/null
+++ b/src/boot-env/syslinux/README.pxe
@@ -0,0 +1,68 @@
+The PXE stuff uses HPAs syslinux, see http://syslinux.zytor.com!
+
+Example how the PXElinux information is gathered:
+
+############################## PXElinux-menu file ##############################
+##### first static information is written, can't be changed #####
+##### override with include-menu (except DEFAULT vesamenu.c32) #####
+# #
+# DEFAULT vesamenu.c32 #
+# NOESCAPE 0 #
+# PROMPT 0 #
+# #
+##### then theme specific information is written (if theme specified) #####
+##### #####
+# #
+# MENU BACKGROUND openslx.png #
+# MENU WIDTH 78 #
+# . #
+# . #
+# menu color unsel 37;40 #fff0f0f0 #ff8093a1 std #
+# . #
+# . #
+# . #
+# #
+##### now slxsettings configuration is being read #####
+##### #####
+# #
+# TIMEOUT 100 #
+# TOTALTIMEOUT 600 #
+# MENU MASTER PASSWD secret #
+# MENU TITLE Welcome to OpenSLX #
+# #
+##### after this /etc/opt/openslx/boot-env/syslinux/pxemenu-include is #####
+##### included if it is existing, overriding above statements #####
+# #
+# MENU PASSPROMPT Gesicherter Bereich, bitte Passwort eingeben: #
+# MENU AUTOBOOT Auswahl startet in # Sekunden #
+# . #
+# . #
+# . #
+# #
+##### at this point the system labels are being included #####
+##### #####
+# #
+# LABEL openslx-suse-11.0-default::nfs #
+# MENU LABEL ^SUSE 11.0 System / NFS #
+# KERNEL suse-11.0-default/vmlinuz-2.6.25.20-0.1-pae #
+# APPEND quiet vga=791 initrd=suse-11.0-default/initramfs-1 file #
+# IPAPPEND 3 #
+# TEXT HELP #
+# OpenSUSE 11.0 System #
+# ENDTEXT #
+# . #
+# . #
+# . #
+# #
+##### at the end /etc/opt/openslx/boot-env/syslinux/pxemenu-bottom is #####
+##### being incl. if existing #####
+##### please specify only systems and further menus #####
+# #
+# MENU SEPARATOR #
+# LABEL test #
+# MENU LABEL ^Testmenu #
+# MENU PASSWD test #
+# KERNEL pxechain.com #
+# APPEND 192.168.1.1::pxelinux.0 #
+# #
+########################## End of PXElinux-menu file ###########################
diff --git a/src/boot-env/syslinux/extlinux b/src/boot-env/syslinux/extlinux
new file mode 100755
index 00000000..69d8bf56
--- /dev/null
+++ b/src/boot-env/syslinux/extlinux
Binary files differ
diff --git a/src/boot-env/syslinux/initramfs-shutdown b/src/boot-env/syslinux/initramfs-shutdown
new file mode 100644
index 00000000..3e4376bd
--- /dev/null
+++ b/src/boot-env/syslinux/initramfs-shutdown
Binary files differ
diff --git a/src/boot-env/syslinux/isolinux.bin b/src/boot-env/syslinux/isolinux.bin
new file mode 100644
index 00000000..bd778b3b
--- /dev/null
+++ b/src/boot-env/syslinux/isolinux.bin
Binary files differ
diff --git a/src/boot-env/syslinux/kernel-shutdown b/src/boot-env/syslinux/kernel-shutdown
new file mode 100644
index 00000000..ddb180dd
--- /dev/null
+++ b/src/boot-env/syslinux/kernel-shutdown
Binary files differ
diff --git a/src/boot-env/syslinux/mboot.c32 b/src/boot-env/syslinux/mboot.c32
new file mode 100755
index 00000000..929ade6f
--- /dev/null
+++ b/src/boot-env/syslinux/mboot.c32
Binary files differ
diff --git a/src/boot-env/syslinux/mbr.bin b/src/boot-env/syslinux/mbr.bin
new file mode 100644
index 00000000..8592b598
--- /dev/null
+++ b/src/boot-env/syslinux/mbr.bin
Binary files differ
diff --git a/src/boot-env/syslinux/menu.c32 b/src/boot-env/syslinux/menu.c32
new file mode 100755
index 00000000..67f9c29b
--- /dev/null
+++ b/src/boot-env/syslinux/menu.c32
Binary files differ
diff --git a/src/boot-env/syslinux/pxechain.com b/src/boot-env/syslinux/pxechain.com
new file mode 100644
index 00000000..8c4e0c5b
--- /dev/null
+++ b/src/boot-env/syslinux/pxechain.com
Binary files differ
diff --git a/src/boot-env/syslinux/pxelinux.0 b/src/boot-env/syslinux/pxelinux.0
new file mode 100644
index 00000000..0df4fbed
--- /dev/null
+++ b/src/boot-env/syslinux/pxelinux.0
Binary files differ
diff --git a/src/boot-env/syslinux/pxemenu-bottom.example b/src/boot-env/syslinux/pxemenu-bottom.example
new file mode 100644
index 00000000..29ceee3c
--- /dev/null
+++ b/src/boot-env/syslinux/pxemenu-bottom.example
@@ -0,0 +1,39 @@
+# this include file will be loaded at the bottom of the menu after the system
+# labels, please define only further menus and systems
+# for theme configuration use theme.conf in your theme directory
+# general settings can be set via slxsettings
+# please copy to pxemenu-bottom if needed
+
+## example: shutdown label in menu
+#LABEL shutdown
+# MENU LABEL ^Shutdown PC
+# KERNEL kernel-shutdown
+# APPEND initrd=initramfs-shutdown quiet
+
+## help label not selectable
+#LABEL help
+# MENU LABEL Press 'F1' for help
+# MENU DISABLE
+
+## example: add an additional menu on the same tftp server
+#LABEL test
+# MENU LABEL ^Testmeu
+# KERNEL vesamenu.c32
+# APPEND testmenu
+
+## example: add an additional menu on a different tftp server, with passwd
+#LABEL test2
+# MENU LABEL ^Testmeu
+# MENU PASSWD test
+# KERNEL pxechain.com
+# APPEND 192.168.101.102::pxelinux.0
+
+## example blank line / menu separator
+#MENU SEPARATOR
+
+## example localboot with passwd
+#LABEL local
+# MENU LABEL Boot from local ^Harddisk
+# MENU PASSWD local
+# localboot 0
+
diff --git a/src/boot-env/syslinux/pxemenu-include.example b/src/boot-env/syslinux/pxemenu-include.example
new file mode 100644
index 00000000..c09f8e70
--- /dev/null
+++ b/src/boot-env/syslinux/pxemenu-include.example
@@ -0,0 +1,58 @@
+# this include file will be loaded at the end of theme and slxsettings
+# configuration but right before the system labels
+# it will overwrite existing defs
+# for theme configuration use theme.conf in your theme directory
+# general settings can be set via slxsettings
+# please copy to pxemenu-include if needed
+
+## example german help:
+#MENU PASSPROMPT Gesicherter Bereich, bitte Passwort eingeben:
+#MENU AUTOBOOT Auswahl startet in # Sekunden
+
+## example: shutdown on timeout
+#ONTIMEOUT shutdown
+#LABEL shutdown
+# MENU HIDE
+# KERNEL kernel-shutdown
+# APPEND initrd=initramfs-shutdown quiet
+
+## example: shutdown label in menu
+#LABEL shutdown2
+# MENU LABEL ^Shutdown PC
+# KERNEL kernel-shutdown
+# APPEND initrd=initramfs-shutdown quiet
+
+## help/... text on F1 keypress
+#F1 help_01.txt
+## optionally with info
+#LABEL help
+# MENU LABEL Press 'F1' for help
+# MENU DISABLE
+
+## example: add an additional menu on the same tftp server
+#LABEL test
+# MENU LABEL ^Testmeu
+# KERNEL vesamenu.c32
+# APPEND testmenu
+
+## example: add an additional menu on a different tftp server, with passwd
+#LABEL test2
+# MENU LABEL ^Testmeu
+# MENU PASSWD test
+# KERNEL pxechain.com
+# APPEND 192.168.101.102::pxelinux.0
+
+## example non-selectable line
+#LABEL -
+# MENU LABEL ________________________________________________________
+# MENU DISABLE
+
+## example blank line / menu separator
+#MENU SEPARATOR
+
+## example localboot with passwd
+#LABEL local
+# MENU LABEL Boot from local ^Harddisk
+# MENU PASSWD local
+# localboot 0
+
diff --git a/src/boot-env/syslinux/syslinux b/src/boot-env/syslinux/syslinux
new file mode 100755
index 00000000..92b1b907
--- /dev/null
+++ b/src/boot-env/syslinux/syslinux
Binary files differ
diff --git a/src/boot-env/syslinux/themes/openslx/openslx.png b/src/boot-env/syslinux/themes/openslx/openslx.png
new file mode 100644
index 00000000..ccf8cc0a
--- /dev/null
+++ b/src/boot-env/syslinux/themes/openslx/openslx.png
Binary files differ
diff --git a/src/boot-env/syslinux/themes/openslx/theme.conf b/src/boot-env/syslinux/themes/openslx/theme.conf
new file mode 100644
index 00000000..e28562d6
--- /dev/null
+++ b/src/boot-env/syslinux/themes/openslx/theme.conf
@@ -0,0 +1,40 @@
+# openslx theme style definition
+# please define only look of your theme
+# for non-theme definitions use slxsettings
+# or include file in /etc/opt/openslx/boot-env/syslinux/pxemenu-include
+
+MENU BACKGROUND openslx.png
+MENU WIDTH 78
+MENU MARGIN 9
+MENU PASSWORDMARGIN 9
+MENU ROWS 10
+MENU TABMSGROW 16
+MENU CMDLINEROW 16
+MENU ENDROW -1
+MENU PASSWORDROW 16
+MENU TIMEOUTROW 20
+MENU HELPMSGROW 16
+MENU HELPMSGENDROW -1
+MENU HSHIFT 0
+MENU VSHIFT 7
+
+menu color screen 37;40 #80ffffff #00000000 std
+menu color border 37;40 #40000000 #ff8093a1 std
+menu color title 1;37;40 #ffff8b00 #ff8093a1 std
+menu color unsel 37;40 #fff0f0f0 #ff8093a1 std
+menu color hotkey 1;37;40 #ffff8b00 #ff8093a1 std
+menu color sel 7;37;40 #ff1c2a33 #667799bb all
+menu color hotsel 1;7;37;40 #ffff8b00 #667799bb all
+menu color disabled 1;37;40 #ffff8b00 #ff8093a1 std
+menu color scrollbar 37;40 #40000000 #ee000000 std
+menu color tabmsg 37;40 #ffff8b00 #ff8093a1 std
+menu color cmdmark 1;37;40 #ffff8b00 #ff8093a1 std
+menu color cmdline 37;40 #fff0f0f0 #ff8093a1 std
+menu color pwdborder 37;40 #40000000 #ff8093a1 std
+menu color pwdheader 37;40 #ffff8b00 #ff8093a1 std
+menu color pwdentry 37;40 #ffff8b00 #ff8093a1 std
+menu color timeout_msg 37;40 #fff0f0f0 #ff8093a1 std
+menu color timeout 1;37;40 #ffff8b00 #ff8093a1 std
+menu color help 37;40 #ff1c2a33 #00000000 none
+MENU MSGCOLOR #ff1c2a33 #00000000 none
+
diff --git a/src/boot-env/syslinux/themes/openslxpbs/openslx.png b/src/boot-env/syslinux/themes/openslxpbs/openslx.png
new file mode 100644
index 00000000..fefbfdf3
--- /dev/null
+++ b/src/boot-env/syslinux/themes/openslxpbs/openslx.png
Binary files differ
diff --git a/src/boot-env/syslinux/themes/openslxpbs/theme.conf b/src/boot-env/syslinux/themes/openslxpbs/theme.conf
new file mode 100644
index 00000000..e28562d6
--- /dev/null
+++ b/src/boot-env/syslinux/themes/openslxpbs/theme.conf
@@ -0,0 +1,40 @@
+# openslx theme style definition
+# please define only look of your theme
+# for non-theme definitions use slxsettings
+# or include file in /etc/opt/openslx/boot-env/syslinux/pxemenu-include
+
+MENU BACKGROUND openslx.png
+MENU WIDTH 78
+MENU MARGIN 9
+MENU PASSWORDMARGIN 9
+MENU ROWS 10
+MENU TABMSGROW 16
+MENU CMDLINEROW 16
+MENU ENDROW -1
+MENU PASSWORDROW 16
+MENU TIMEOUTROW 20
+MENU HELPMSGROW 16
+MENU HELPMSGENDROW -1
+MENU HSHIFT 0
+MENU VSHIFT 7
+
+menu color screen 37;40 #80ffffff #00000000 std
+menu color border 37;40 #40000000 #ff8093a1 std
+menu color title 1;37;40 #ffff8b00 #ff8093a1 std
+menu color unsel 37;40 #fff0f0f0 #ff8093a1 std
+menu color hotkey 1;37;40 #ffff8b00 #ff8093a1 std
+menu color sel 7;37;40 #ff1c2a33 #667799bb all
+menu color hotsel 1;7;37;40 #ffff8b00 #667799bb all
+menu color disabled 1;37;40 #ffff8b00 #ff8093a1 std
+menu color scrollbar 37;40 #40000000 #ee000000 std
+menu color tabmsg 37;40 #ffff8b00 #ff8093a1 std
+menu color cmdmark 1;37;40 #ffff8b00 #ff8093a1 std
+menu color cmdline 37;40 #fff0f0f0 #ff8093a1 std
+menu color pwdborder 37;40 #40000000 #ff8093a1 std
+menu color pwdheader 37;40 #ffff8b00 #ff8093a1 std
+menu color pwdentry 37;40 #ffff8b00 #ff8093a1 std
+menu color timeout_msg 37;40 #fff0f0f0 #ff8093a1 std
+menu color timeout 1;37;40 #ffff8b00 #ff8093a1 std
+menu color help 37;40 #ff1c2a33 #00000000 none
+MENU MSGCOLOR #ff1c2a33 #00000000 none
+
diff --git a/src/boot-env/syslinux/vesamenu.c32 b/src/boot-env/syslinux/vesamenu.c32
new file mode 100755
index 00000000..804e2fb8
--- /dev/null
+++ b/src/boot-env/syslinux/vesamenu.c32
Binary files differ