summaryrefslogtreecommitdiffstats
path: root/config-db/slxconfig-demuxer
diff options
context:
space:
mode:
authorOliver Tappe2008-02-02 17:54:04 +0100
committerOliver Tappe2008-02-02 17:54:04 +0100
commit4d9953a280612e0d995960bb9f2eb78b95469779 (patch)
treec086f78303349f6e0235c3f2d3881128d5b3352f /config-db/slxconfig-demuxer
parent* finished initial re-implementation of mkdxsinitrd in perl - (diff)
downloadcore-4d9953a280612e0d995960bb9f2eb78b95469779.tar.gz
core-4d9953a280612e0d995960bb9f2eb78b95469779.tar.xz
core-4d9953a280612e0d995960bb9f2eb78b95469779.zip
* added support for creating only the initramfs for the systems that
have been given on the cmdline (the demuxing will still be done for all systems). * as a result of this, the generated initramfs-files now contain the id of the system as part of their name instead of a per-vendor-OS counter - the latter has become cumbersome now that we no longer generate all initramfs in every run. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1509 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/slxconfig-demuxer')
-rwxr-xr-xconfig-db/slxconfig-demuxer77
1 files changed, 57 insertions, 20 deletions
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index 430e1772..e85e0c55 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -30,10 +30,12 @@ slxconfig-demuxer
];
use Config::General;
+use Digest::MD5 qw(md5_hex);
use Fcntl qw(:DEFAULT :flock);
use File::Basename;
use File::Find;
use File::Path;
+use List::Util qw(first);
use Getopt::Long qw(:config pass_through);
use Pod::Usage;
use Storable qw(dclone);
@@ -74,11 +76,12 @@ my (
# number of systems that had errors
$clientSystemConfCount,
# number of (system-specific) client configurations written
- %vendorOSInitramfsMap,
- # keeping note of how many initramFSs have been created for a
- # specific vendor-OS.
+ $initramfsCount,
+ # number of initramfs that were created
$makeInitRamFS,
# generate initial ramfs internally (new style)
+ @targetSystems,
+ # systems to create initramfs for, defaults to all systems
$helpReq,
$manReq,
$versionReq,
@@ -150,12 +153,45 @@ if (!$dryRun) {
}
}
my $tftpbootPath = "$openslxConfig{'public-path'}/tftpboot";
-if (!$dryRun) {
- slxsystem("rm -rf $tftpbootPath/*");
- mkpath( [ "$tftpbootPath/client-config", "$tftpbootPath/pxelinux.cfg" ] );
- if (!-d $tftpbootPath) {
- die _tr("Unable to create or access tftpboot-path '%s'!",
- $tftpbootPath);
+
+my @demuxableSystems
+ = grep { $_->{name} ne '<<<default>>>' } $openslxDB->fetchSystemByFilter();
+if (@ARGV) {
+ # create initramfs only for systems given on cmdline
+ for my $systemName (@ARGV) {
+ if ($systemName eq '<<<default>>>') {
+ warn _tr(
+ 'The default-system can not be demuxed - it will be skipped.'
+ );
+ next;
+ }
+ my $system = first { $_->{name} eq $systemName } @demuxableSystems;
+ if (!$system) {
+ warn _tr(
+ 'The system "%s" is unknown and will be ignored.', $systemName
+ );
+ next;
+ }
+ push @targetSystems, $system;
+ }
+
+ # remove only the folders of the target systems
+ if (!$dryRun) {
+ rmtree("$tftpbootPath/pxelinux.cfg");
+ mkpath(["$tftpbootPath/client-config", "$tftpbootPath/pxelinux.cfg"]);
+ for my $targetSystem (@targetSystems) {
+ rmtree("$tftpbootPath/client-config/$targetSystem");
+ }
+ }
+}
+else {
+ # create initramfs for all systems
+ @targetSystems = @demuxableSystems;
+
+ # and cleanup everything
+ if (!$dryRun) {
+ rmtree("$tftpbootPath");
+ mkpath(["$tftpbootPath/client-config", "$tftpbootPath/pxelinux.cfg"]);
}
}
@@ -165,6 +201,7 @@ my $wr = $dryRun ? 'would have written' : 'wrote';
my $errCount = $systemErrCount ? $systemErrCount : 'no';
print "\n", unshiftHereDoc(<<"End-of-Here");
$wr $systemConfCount system- and $clientSystemConfCount client-specific configurations to $tftpbootPath/client-config
+ $initramfsCount initramfs were created
$errCount system(s) had errors
End-of-Here
@@ -250,7 +287,6 @@ sub digestAttributes
keys %$attrs;
vlog(3, "Attribute-string: $attrsAsString");
- use Digest::MD5 qw(md5_hex);
return md5_hex($attrsAsString);
}
@@ -593,6 +629,8 @@ sub writeSystemPXEFiles
{
my $info = shift;
+ vlog(0, _tr('copying kernel and creating initramfs'));
+
my $kernelFile = $info->{'kernel-file'};
my $kernelName = basename($kernelFile);
@@ -605,15 +643,12 @@ sub writeSystemPXEFiles
vlog(1, _tr('copying kernel %s to %s', $kernelFile, $targetKernel));
slxsystem(qq[cp -p "$kernelFile" "$targetKernel"]) unless $dryRun;
}
- $vendorOSInitramfsMap{$info->{'vendor-os'}->{id}}++;
- $info->{'initramfs-name'} =
- sprintf("initramfs-%d",
- $vendorOSInitramfsMap{$info->{'vendor-os'}->{id}});
if ($makeInitRamFS) {
makeInitRamFS($info, $pxeVendorOSPath);
} else {
generateInitialRamFS($info, $pxeVendorOSPath);
}
+ $initramfsCount++;
return;
}
@@ -784,7 +819,11 @@ sub writeSystemConfiguration
my $systemPath = "$tftpbootPath/client-config/$info->{'external-id'}";
createTarOfPath($buildPath, "default.tgz", $systemPath);
- writeSystemPXEFiles($info);
+ # copy kernel and generate initramfs only if this is a target system
+ $info->{'initramfs-name'} = "initramfs-$info->{id}";
+ if (grep { $_->{name} eq $info->{name} } @targetSystems) {
+ writeSystemPXEFiles($info);
+ }
writeClientConfigurationsForSystem($info, $buildPath, $attrFile);
@@ -794,12 +833,10 @@ sub writeSystemConfiguration
sub writeConfigurations
{
- $systemConfCount = $systemErrCount = $clientSystemConfCount = 0;
- my @systems = $openslxDB->fetchSystemByFilter();
+ $initramfsCount = $systemConfCount = $systemErrCount
+ = $clientSystemConfCount = 0;
my @infos;
- foreach my $system (@systems) {
- next if $system->{name} eq '<<<default>>>';
-
+ foreach my $system (@demuxableSystems) {
vlog(
0, _tr("\ndemuxing system %d : %s", $system->{id}, $system->{name})
);