summaryrefslogtreecommitdiffstats
path: root/boot-env/OpenSLX/BootEnvironment/PXE.pm
diff options
context:
space:
mode:
Diffstat (limited to 'boot-env/OpenSLX/BootEnvironment/PXE.pm')
-rw-r--r--boot-env/OpenSLX/BootEnvironment/PXE.pm125
1 files changed, 74 insertions, 51 deletions
diff --git a/boot-env/OpenSLX/BootEnvironment/PXE.pm b/boot-env/OpenSLX/BootEnvironment/PXE.pm
index 7ab52912..fb98e967 100644
--- a/boot-env/OpenSLX/BootEnvironment/PXE.pm
+++ b/boot-env/OpenSLX/BootEnvironment/PXE.pm
@@ -105,7 +105,14 @@ sub writeBootloaderMenuFor
my $helpText = $info->{description} || '';
if (length($helpText)) {
# make sure that text matches the given margin
- my $margin = $openslxConfig{'pxe-theme-menu-margin'} || 0;
+ my $menuMargin;
+ while ($pxeConfig =~ m{^\s*MENU MARGIN (\S+?)\s*$}gims) {
+ chomp($menuMargin = $1);
+ }
+ my $margin
+ = defined $menuMargin
+ ? "$menuMargin"
+ : "0";
my $marginAsText = ' ' x $margin;
$helpText =~ s{^}{$marginAsText}gms;
$slxLabels .= "\tTEXT HELP\n$helpText\n\tENDTEXT\n";
@@ -130,78 +137,94 @@ sub _getTemplate
return $self->{'pxe-template'} if $self->{'pxe-template'};
- my $pxeDefaultTemplate = unshiftHereDoc(<<' End-of-Here');
- NOESCAPE 0
- PROMPT 0
- TIMEOUT 100
- DEFAULT menu.c32
- IMPLICIT 1
- ALLOWOPTIONS 1
- MENU TITLE Was möchten Sie tun (Auswahl mittels Cursortasten)?
- MENU MASTER PASSWD secret
- End-of-Here
- utf8::decode($pxeDefaultTemplate);
-
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);
- # fetch PXE-template, if any
+ # generate PXE-Menu
my $pxeTemplate =
"# generated by slxconfig-demuxer (on $callDate at $callTime)\n";
- my $pxeTemplateFile
- = "$openslxConfig{'config-path'}/boot-env/pxe/menu-template";
- if (-e $pxeTemplateFile) {
- $pxeTemplate .= slurpFile($pxeTemplateFile);
- } else {
- $pxeTemplate .= $pxeDefaultTemplate;
- }
- # now append (and thus override) the PXE-template with the settings of the
- # selected PXE-theme, if any
+ # first check for theme
my $basePath = $openslxConfig{'base-path'};
my $configPath = $openslxConfig{'config-path'};
+ my $tftpServer = $openslxConfig{'tftp-server-ip'};
my $pxeTheme = $openslxConfig{'pxe-theme'};
- if (defined $pxeTheme) {
- # let user stuff in config path win over our stuff in base path
- my $pxeThemeInConfig
- = "$configPath/boot-env/pxe/themes/${pxeTheme}/theme.conf";
- if (-e $pxeThemeInConfig) {
- $pxeTemplate .= slurpFile($pxeThemeInConfig);
- }
- else {
- my $pxeThemeInBase
- = "$basePath/share/boot-env/pxe/themes/${pxeTheme}/theme.conf";
- if (-e $pxeThemeInBase) {
- $pxeTemplate .= slurpFile($pxeThemeInBase);
- }
- }
+ if (defined $tftpServer) {
+ $tftpServer .= "::"
+ }
+ else {
+ $tftpServer = "";
}
- # fetch info about margin and replace the corresponding placeholders
- my $margin = $openslxConfig{'pxe-theme-menu-margin'} || 0;
- my $marginAsText = ' ' x $margin;
- $pxeTemplate =~ s{\@\@\@MENU_MARGIN\@\@\@}{$margin}g;
- my $separatorLine = '-' x (78 - 4 - 2 * $margin);
- $pxeTemplate =~ s{\@\@\@SEPARATOR_LINE\@\@\@}{$separatorLine}g;
+ # let user stuff in config path win over our stuff in base path
+ my $pxeThemePath;
+ my $pxeThemeInConfig
+ = "$configPath/boot-env/pxe/themes/${pxeTheme}";
+ my $pxeThemeInBase
+ = "$basePath/share/boot-env/pxe/themes/${pxeTheme}";
+ if (-e "$pxeThemeInConfig/theme.conf") {
+ $pxeThemePath = $pxeThemeInConfig;
+ }
+ else {
+ if (-e "$pxeThemeInBase/theme.conf") {
+ $pxeThemePath = $pxeThemeInBase;
+ }
+ }
+ # include theme specific stuff from above
+ if (defined $pxeThemePath) {
+ $pxeTemplate .= "\n# theme specific configuration from $pxeThemePath\n";
+ $pxeTemplate .= slurpFile("$pxeThemePath/theme.conf");
+ }
- # pick out the last background picture and copy it over
+ # copy background picture if exists
my $pic;
- while ($pxeTemplate =~ m{^\s*MENU BACKGROUND (\S+?)\s*$}gims) {
- chomp($pic = $1);
+ if (defined $pxeTheme) {
+ while ($pxeTemplate =~ m{^\s*MENU BACKGROUND (\S+?)\s*$}gims) {
+ chomp($pic = $1);
+ }
+ my $picPrefix = $tftpServer;
+ $picPrefix .= $pic;
+ $pxeTemplate =~ s,$pic,$picPrefix,g;
}
if (defined $pic) {
- my $pxeBackground
- = defined $pxeTheme
- ? "$basePath/share/themes/${pxeTheme}/pxe/$pic"
- : $pic;
+ my $pxeBackground = "$pxeThemePath/$pic";
+ # vesamenu.c32 if $pic
+ $pxeTemplate .= "\nDEFAULT $tftpServer";
+ $pxeTemplate .= "vesamenu.c32\n";
if (-e $pxeBackground && !$self->{'dry-run'}) {
slxsystem(qq[cp "$pxeBackground" $self->{'target-path'}/]);
}
}
-
+ else {
+ # we only need menu.c32 if no $pic
+ $pxeTemplate .= "\nDEFAULT $tftpServer";
+ $pxeTemplate .= "menu.c32\n";
+ }
+
+ # include defaults
+ $pxeTemplate .= "\n# general configuration\n";
+ $pxeTemplate .= "NOESCAPE 0\n";
+ $pxeTemplate .= "PROMPT 0\n";
+
+ # include slxsettings
+ $pxeTemplate .= "\n# slxsettings configuration\n";
+ $pxeTemplate .= "TIMEOUT $openslxConfig{'pxe-timeout'}\n" || "";
+ $pxeTemplate .= "TOTALTIMEOUT $openslxConfig{'pxe-totaltimeout'}\n" || "";
+ $pxeTemplate .= "MENU MASTER PASSWD $openslxConfig{'pxe-passwd'}\n" || "";
+ $pxeTemplate .= "MENU TITLE $openslxConfig{'pxe-title'}\n" || "";
+
+ # fetch PXE-include, if exists (overwrite existing definitions)
+ my $pxeIncludeFile
+ = "$openslxConfig{'config-path'}/boot-env/pxe/menu-include";
+ if (-e $pxeIncludeFile) {
+ $pxeTemplate .= "\n# configuration from include $pxeIncludeFile\n";
+ $pxeTemplate .= slurpFile($pxeIncludeFile);
+ }
+
+ $pxeTemplate .= "\n# slxsystems:\n";
$self->{'pxe-template'} = $pxeTemplate;
return $pxeTemplate;