From 2ddbcd32c1262791ff9a8a0367063e2332aea903 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Thu, 22 Nov 2012 12:37:46 +0100 Subject: change config structure: - old config, which was based only on stage3 wasn't modified. Only the directory has changed to /config/stage3 - stage1 config, which wasn't possible this way before, can be done now in /config/stage1 - the default/rootfs directory will be used for every vendor-OS - /config/stage1//rootfs will be used for the corresponding vendor-OS - so after a clone/install/update of stage1 the dafault config will be rsynced and after that the vendor-OS specific config will be rsynced. At the end the plugins will be installed. - This is all part of slxos-setup. ' --- src/installer/OpenSLX/OSSetup/Engine.pm | 91 ++++++++++++++++++++++++++++++++- src/installer/slxos-setup | 2 + 2 files changed, 92 insertions(+), 1 deletion(-) (limited to 'src/installer') diff --git a/src/installer/OpenSLX/OSSetup/Engine.pm b/src/installer/OpenSLX/OSSetup/Engine.pm index 2a4463e5..159a23a7 100644 --- a/src/installer/OpenSLX/OSSetup/Engine.pm +++ b/src/installer/OpenSLX/OSSetup/Engine.pm @@ -32,6 +32,7 @@ use File::Path; use URI; use OpenSLX::Basics; +use OpenSLX::ConfigFolder; use OpenSLX::ScopedResource; use OpenSLX::Syscall; use OpenSLX::Utils; @@ -229,6 +230,10 @@ sub initialize $self->_createMetaPackager(); } + # create stage1 config folder + createConfigFolderForDefaultVendorOS(); + createConfigFolderForVendorOS($self->{'vendor-os-name'}); + return; } @@ -299,6 +304,22 @@ sub installVendorOS # generate default openslx directories for the client $self->_generateDefaultDirs(); + # copy stage1 config ... + # first copy default files ... + my $defaultConfigPath = "$openslxConfig{'private-path'}" . + "/config/stage1/default/rootfs/"; + vlog(2, "checking $defaultConfigPath for default config..."); + if (-d $defaultConfigPath) { + $self->_copyStage1Config($defaultConfigPath); + } + # ... now pour system-specific configuration on top (if any) ... + my $vendorOSConfigPath = "$openslxConfig{'private-path'}/config/stage1/" . + "$self->{'vendor-os-name'}/rootfs/"; + vlog(2, "checking $vendorOSConfigPath for system config..."); + if (-d $vendorOSConfigPath) { + $self->_copyStage1Config($vendorOSConfigPath); + } + # add the initramfs rootfs and tools to the stage1 $self->_copyRootfs(); #callInSubprocess( @@ -400,7 +421,23 @@ sub cloneVendorOS # generate default openslx directories for the client $self->_generateDefaultDirs(); - + + # copy stage1 config ... + # first copy default files ... + my $defaultConfigPath = "$openslxConfig{'private-path'}" . + "/config/stage1/default/rootfs/"; + vlog(2, "checking $defaultConfigPath for default config..."); + if (-d $defaultConfigPath) { + $self->_copyStage1Config($defaultConfigPath); + } + # ... now pour system-specific configuration on top (if any) ... + my $vendorOSConfigPath = "$openslxConfig{'private-path'}/config/stage1/" . + "$self->{'vendor-os-name'}/rootfs/"; + vlog(2, "checking $vendorOSConfigPath for system config..."); + if (-d $vendorOSConfigPath) { + $self->_copyStage1Config($vendorOSConfigPath); + } + # add the initramfs rootfs and tools to the stage1 $self->_copyRootfs(); $self->_touchVendorOS(); @@ -431,6 +468,23 @@ sub updateVendorOS ); $self->_generateDefaultDirs(); + + # copy stage1 config ... + # first copy default files ... + my $defaultConfigPath = "$openslxConfig{'private-path'}" . + "/config/stage1/default/rootfs/"; + vlog(2, "checking $defaultConfigPath for default config..."); + if (-d $defaultConfigPath) { + $self->_copyStage1Config($defaultConfigPath); + } + # ... now pour system-specific configuration on top (if any) ... + my $vendorOSConfigPath = "$openslxConfig{'private-path'}/config/stage1/" . + "$self->{'vendor-os-name'}/rootfs/"; + vlog(2, "checking $vendorOSConfigPath for system config..."); + if (-d $vendorOSConfigPath) { + $self->_copyStage1Config($vendorOSConfigPath); + } + $self->_copyRootfs(); $self->_touchVendorOS(); vlog( @@ -1194,6 +1248,41 @@ sub _copyRootfs return; } +sub _copyStage1Config +{ + my $self = shift; + my $source = shift; + + vlog( + 0, + _tr( + "Copying vendor-OS config from '%s' to '%s'...\n", $source, + $self->{'vendor-os-path'} + ) + ); + my $additionalRsyncOptions = $ENV{SLX_RSYNC_OPTIONS} || ''; + my $rsyncCmd + = "rsync -av --numeric-ids $additionalRsyncOptions" + . " $source $self->{'vendor-os-path'}"; + vlog(2, "executing: $rsyncCmd\n"); + my $rsyncFH; + open($rsyncFH, '|-', $rsyncCmd) + or croak( + _tr( + "unable to start rsync for source '%s', giving up! (%s)\n", + $source, $! + ) + ); + print $rsyncFH; + if (!close($rsyncFH)) { + print "rsync-result=", 0+$!, "\n"; + croak _tr( + "unable to clone from source '%s', giving up! (%s)\n", $source, $! + ); + } + return; +} + sub _createPackager { my $self = shift; diff --git a/src/installer/slxos-setup b/src/installer/slxos-setup index 8812a19b..30c9287b 100755 --- a/src/installer/slxos-setup +++ b/src/installer/slxos-setup @@ -80,6 +80,8 @@ if ($action =~ m[^import]i) { die _tr("'%s' doesn't exist, giving up!\n", $engine->{'vendor-os-path'}); } $engine->addInstalledVendorOSToConfigDB(); + createConfigFolderForDefaultVendorOS(); + createConfigFolderForVendorOS($vendorOSName); } elsif ($action =~ m[^update]i) { my $vendorOSName = shift @ARGV; if (!defined $vendorOSName) { -- cgit v1.2.3-55-g7522