diff options
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; } |