summaryrefslogtreecommitdiffstats
path: root/config-db/slxconfig-demuxer
diff options
context:
space:
mode:
authorOliver Tappe2007-04-11 20:02:47 +0200
committerOliver Tappe2007-04-11 20:02:47 +0200
commitb2e68d603a8ddcd251b9758ea80ea083e3102b8f (patch)
tree5f2fe25e3a345321faa982d9697f0183cd1f03a3 /config-db/slxconfig-demuxer
parent* created example of a PXE-template file and changed Makefile to copy (diff)
downloadcore-b2e68d603a8ddcd251b9758ea80ea083e3102b8f.tar.gz
core-b2e68d603a8ddcd251b9758ea80ea083e3102b8f.tar.xz
core-b2e68d603a8ddcd251b9758ea80ea083e3102b8f.zip
* now supports external PXE-template (expected in '/etc/opt/openslx/PXE-template').
* no longer leaves .lock-file in case of death git-svn-id: http://svn.openslx.org/svn/openslx/trunk@877 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/slxconfig-demuxer')
-rwxr-xr-xconfig-db/slxconfig-demuxer29
1 files changed, 21 insertions, 8 deletions
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index 13d395c8..ad7f1675 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -44,15 +44,16 @@ use lib "$FindBin::RealBin";
use OpenSLX::Basics;
use OpenSLX::ConfigDB qw(:support);
+use OpenSLX::Utils;
-my $pxeConfigDefaultTemplate = q[# generated by openslx
-NOESCAPE 0
+my $pxeDefaultTemplate =
+q[NOESCAPE 0
PROMPT 0
TIMEOUT 10
DEFAULT menu.c32
IMPLICIT 1
ALLOWOPTIONS 1
-MENU TITLE What would you like to do? (use cursor to select)
+MENU TITLE Was möchten Sie tun (Auswahl mittels Cursortasten)?
MENU MASTER PASSWD secret
];
@@ -91,6 +92,10 @@ if ($versionReq) {
exit 1;
}
+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);
+
openslxInit();
my $openslxDB = OpenSLX::ConfigDB->new();
@@ -121,6 +126,8 @@ if (!$dryRun) {
my $lockFile = "$tftpbootPath/config-demuxer.lock";
lockScript($lockFile);
+END { unlockScript($lockFile); }
+
writeConfigurations();
my $wr = ($dryRun ? "would have written" : "wrote");
@@ -130,8 +137,6 @@ $openslxDB->disconnect();
system("rm -rf $tempPath") unless $dryRun || length($tempPath) < 12;
-unlockScript($lockFile);
-
exit;
################################################################################
@@ -266,6 +271,15 @@ sub writePXEMenus
system(qq[cp -p "$menuc32Path" $pxePath/]);
}
+ # fetch PXE-template, if any:
+ my $pxeTemplate = "# generated by slxconfig-demuxer (on $callDate at $callTime)\n";
+ my $pxeTemplateFile = "$openslxConfig{'config-path'}/PXE-template";
+ if (-e $pxeTemplateFile) {
+ $pxeTemplate .= slurpFile($pxeTemplateFile);
+ } else {
+ $pxeTemplate .= $pxeDefaultTemplate;
+ }
+
my @clients = $openslxDB->fetchClientByFilter();
foreach my $client (@clients) {
my $externalClientID = externalIDForClient($client);
@@ -273,7 +287,7 @@ sub writePXEMenus
my $clientAppend = $client->{kernel_params};
vlog 1, _tr("writing PXE-file %s", $pxeFile);
open(PXE, "> $pxeFile") or die "unable to write to $pxeFile";
- print PXE $pxeConfigDefaultTemplate;
+ print PXE $pxeTemplate;
my @systemIDs = $openslxDB->aggregatedSystemIDsOfClient($client);
my @systems = $openslxDB->fetchSystemByID(\@systemIDs);
foreach my $system (@systems) {
@@ -322,8 +336,7 @@ sub generateInitalRamFS
# fill slxConf-hash...
my %slxConf;
# ...set date initrd has been generated...
- my ($d, $m, $y) = (localtime)[3,4,5]; $m++; $y+=1900;
- $slxConf{'slxconf_date'} = sprintf('%04d-%02d-%02d', $y, $m, $d);
+ $slxConf{'slxconf_date'} = $callDate;
# ...set kernel version...
my $kernelFile = readlink($setup->{'kernel-file'});
$kernelFile =~ m[-(.+)$];