diff options
author | Oliver Tappe | 2008-01-11 11:13:53 +0100 |
---|---|---|
committer | Oliver Tappe | 2008-01-11 11:13:53 +0100 |
commit | c52faf87a3b98200e52d1a80bc1c0c48faeedf4e (patch) | |
tree | b8d7fff78347c3463905833df84a4f9b7245a1d4 /config-db/slxconfig-demuxer | |
parent | * added implementation for zypper meta-packager (untested yet) (diff) | |
download | core-c52faf87a3b98200e52d1a80bc1c0c48faeedf4e.tar.gz core-c52faf87a3b98200e52d1a80bc1c0c48faeedf4e.tar.xz core-c52faf87a3b98200e52d1a80bc1c0c48faeedf4e.zip |
* added new column 'description' to system, which holds an optional
descriptive text that is going to be shown via PXE TEXT (as outlined
by Michael in his work on PXE themes)
* made setup of DB upgrade functions less error-prone (it is now harder
to forget parts of the necessary setup)
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1458 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/slxconfig-demuxer')
-rwxr-xr-x | config-db/slxconfig-demuxer | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer index 2085461e..9558d1ca 100755 --- a/config-db/slxconfig-demuxer +++ b/config-db/slxconfig-demuxer @@ -29,6 +29,7 @@ slxconfig-demuxer Please use the --man option in order to read the full manual. ]; +use Config::General; use Fcntl qw(:DEFAULT :flock); use File::Basename; use File::Find; @@ -362,7 +363,7 @@ sub writePXEMenus slxsystem(qq[cp -p "$vesamenuc32Path" $pxePath/]) unless $dryRun; } - # fetch PXE-template, if any: + # fetch PXE-template, if any my $pxeTemplate = "# generated by slxconfig-demuxer (on $callDate at $callTime)\n"; my $pxeTemplateFile = "$openslxConfig{'config-path'}/PXE-template"; @@ -371,40 +372,65 @@ sub writePXEMenus } else { $pxeTemplate .= $pxeDefaultTemplate; } + + # now append (and thus override) the PXE-template with the settings of the + # selected PXE-theme, if any + my $pxeTheme = $openslxConfig{'pxe-theme'}; + my $pxeThemeConfig + = "$openslxConfig{'base-path'}/share/themes/${pxeTheme}/pxe/theme.conf"; + if (-e $pxeThemeConfig) { + $pxeTemplate .= slurpFile($pxeThemeConfig); + } + # 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... use Encode 'from_to'; from_to($pxeTemplate, 'utf-8', 'cp850'); + # pick out the last background picture and copy it over + my $pic; + while ($pxeTemplate =~ m{^\s*MENU BACKGROUND (\S+?)\s*$}gims) { + chomp($pic = $1); + } + if (defined $pic) { + my $pxeBackground + = "$openslxConfig{'base-path'}/share/themes/${pxeTheme}/pxe/$pic"; + if (-e $pxeBackground) { + slxsystem(qq[cp "$pxeBackground" $pxePath/]) unless $dryRun; + } + } + my @clients = $openslxDB->fetchClientByFilter(); foreach my $client (@clients) { + my $pxeConfig = $pxeTemplate; my $externalClientID = externalIDForClient($client); my $pxeFile = "$pxeConfigPath/$externalClientID"; my $clientAppend = $client->{kernel_params} || ''; vlog(1, _tr("writing PXE-file %s", $pxeFile)); next if $dryRun; - my $pxeFH; - open($pxeFH, '>', $pxeFile) - or croak _tr("unable to create file '%s' (%s)\n", $pxeFile, $!); - print $pxeFH $pxeTemplate; my %systemIDs; @systemIDs{$openslxDB->aggregatedSystemIDsOfClient($client)} = (); my @systemInfos = grep { exists $systemIDs{$_->{id}} } @infos; # now @systemInfos holds all infos relevant to this client + my $slxLabels = ''; foreach my $info (@systemInfos) { my $extID = $info->{'vendor-os'}->{name}; my $kernelName = basename($info->{'kernel-file'}); my $append = $info->{kernel_params}; $append .= " initrd=$extID/$info->{'initramfs-name'}"; $append .= " $clientAppend"; - print $pxeFH "LABEL openslx-$info->{'external-id'}\n"; - print $pxeFH "\tMENU LABEL ^$info->{label}\n"; - print $pxeFH "\tKERNEL $extID/$kernelName\n"; - print $pxeFH "\tAPPEND $append\n"; - print $pxeFH "\tIPAPPEND 1\n"; + $slxLabels .= "LABEL openslx-$info->{'external-id'}\n"; + $slxLabels .= "\tMENU LABEL ^$info->{label}\n"; + $slxLabels .= "\tKERNEL $extID/$kernelName\n"; + $slxLabels .= "\tAPPEND $append\n"; + $slxLabels .= "\tIPAPPEND 1\n"; + } +$slxLabels .= $slxLabels . $slxLabels . $slxLabels . $slxLabels; + # now add the slx-labels (inline or appended) and write the config file + if (!($pxeConfig =~ s{\@\@\@SLX_LABELS\@\@\@}{$slxLabels})) { + $pxeConfig .= $slxLabels; } - close($pxeFH) - or croak _tr("unable to close file '%s' (%s)\n", $pxeFile, $!); + spitFile($pxeFile, $pxeConfig); } return; } |