summaryrefslogtreecommitdiffstats
path: root/boot-env/OpenSLX/BootEnvironment/PXE.pm
diff options
context:
space:
mode:
authorMichael Janczyk2009-04-02 18:39:32 +0200
committerMichael Janczyk2009-04-02 18:39:32 +0200
commitd3dd8a4b7ab0b81783c12d727045bae357cbda8e (patch)
treefd096ddae6fd4971d56725dc27c8a469df9dc774 /boot-env/OpenSLX/BootEnvironment/PXE.pm
parentvmchooser binary: (diff)
downloadcore-d3dd8a4b7ab0b81783c12d727045bae357cbda8e.tar.gz
core-d3dd8a4b7ab0b81783c12d727045bae357cbda8e.tar.xz
core-d3dd8a4b7ab0b81783c12d727045bae357cbda8e.zip
disputable realization of pxe-theme as default
openslx theme will now be used as default all theming definitions should take place in a separate file general configuration should take place via slxsettings pxe-passwd='secret' pxe-theme='openslx' pxe-timeout='100' pxe-title='Welcome to OpenSLX' pxe-totaltimeout='600' tftp-server-ip='132.230.4.4' for further tests an include file in etc/opt could be used, which will be loaded at the end i had to introduce tftp-server-ip in slxsettings since i need the ip for (vesa)menu.c32 and the image do you thionk it's to complicated now? we can still change it, any better ideas, simplifications? git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2793 95ad53e4-c205-0410-b2fa-d234c58c8868
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;