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/bin/slxsettings | 1 + .../OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm | 2 +- src/config-db/slxconfig-demuxer | 13 ++-- src/installer/OpenSLX/OSSetup/Engine.pm | 91 +++++++++++++++++++++- src/installer/slxos-setup | 2 + src/lib/OpenSLX/ConfigFolder.pm | 33 +++++++- 6 files changed, 132 insertions(+), 10 deletions(-) diff --git a/src/bin/slxsettings b/src/bin/slxsettings index 8c6a823d..2748a33f 100755 --- a/src/bin/slxsettings +++ b/src/bin/slxsettings @@ -223,6 +223,7 @@ sub private_path_changed_handler # create the default config folders (for default system only): require OpenSLX::ConfigFolder; OpenSLX::ConfigFolder::createConfigFolderForDefaultSystem(); + OpenSLX::ConfigFolder::createConfigFolderForDefaultVendorOS(); return; } diff --git a/src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm index 82f46103..a0c24edb 100644 --- a/src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm +++ b/src/boot-env/OpenSLX/MakeInitRamFS/Engine/SlxBoot.pm @@ -239,7 +239,7 @@ sub _copyPreAndPostinitFiles 'default/initramfs/postinit.local', "$self->{'system-name'}/initramfs/postinit.local" ) { - my $cfgPath = "$openslxConfig{'private-path'}/config/$cfg"; + my $cfgPath = "$openslxConfig{'private-path'}/config/stage3/$cfg"; next if !-f $cfgPath; $self->addCMD("cp -p $cfgPath $self->{'build-path'}/bin/"); } diff --git a/src/config-db/slxconfig-demuxer b/src/config-db/slxconfig-demuxer index dadd814b..ef2978fc 100755 --- a/src/config-db/slxconfig-demuxer +++ b/src/config-db/slxconfig-demuxer @@ -101,7 +101,7 @@ openslxInit(); my $openslxDB = OpenSLX::ConfigDB->new(); $openslxDB->connect(); -my $clientConfigPath = "$openslxConfig{'private-path'}/config"; +my $clientConfigPath = "$openslxConfig{'private-path'}/config/stage3"; # make sure that the default config folders exist: if (createConfigFolderForDefaultSystem()) { # this path should have been generated by earlier stage (slxsettings), so @@ -266,8 +266,8 @@ sub writeSlxConfigToFile } sub copyExternalSystemConfig -{ # copies local configuration extensions of given system from private - # config folder (var/lib/openslx/config/...) into a temporary folder +{ # copies local configuration extensions of given system from private config + # folder (var/lib/openslx/config/stage3/...) into a temporary folder my $systemName = shift; my $targetPath = shift; my $clientName = shift; # optional @@ -827,13 +827,14 @@ specifying all the attributes of that particular system and/or client Furthermore, each system-specific archive may contain additional system files that are required for that system (e.g. a special PAM-module required for LDAP -authentication). These files are copied from F<$SLX_PRIVATE_PATH/config/default> -and F<$SLX_PROVATE_PATH/config/>. +authentication). These files are copied from +F<$SLX_PRIVATE_PATH/config/stage3/default> and +F<$SLX_PROVATE_PATH/config/stage3/>. On top of that, each client may have its own set of system files, too (e.g. some config files required to install a special kind of hardware available only on that client). These files are copied from -F<< $SLX_PROVATE_PATH/config//01- >>. +F<< $SLX_PROVATE_PATH/config/stage3//01- >>. =back 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) { diff --git a/src/lib/OpenSLX/ConfigFolder.pm b/src/lib/OpenSLX/ConfigFolder.pm index fd52821e..ac5d9325 100644 --- a/src/lib/OpenSLX/ConfigFolder.pm +++ b/src/lib/OpenSLX/ConfigFolder.pm @@ -21,7 +21,9 @@ $VERSION = 1.01; @EXPORT = qw( &createConfigFolderForDefaultSystem + &createConfigFolderForDefaultVendorOS &createConfigFolderForSystem + &createConfigFolderForVendorOS ); =head1 NAME @@ -66,7 +68,8 @@ required folders & files already existed. sub createConfigFolderForDefaultSystem { my $result = 0; - my $defaultConfigPath = "$openslxConfig{'private-path'}/config/default"; + my $defaultConfigPath = + "$openslxConfig{'private-path'}/config/stage3/default"; if (!-e "$defaultConfigPath/initramfs") { slxsystem("mkdir -p $defaultConfigPath/initramfs"); $result = 1; @@ -111,6 +114,18 @@ sub createConfigFolderForDefaultSystem return $result; } +sub createConfigFolderForDefaultVendorOS +{ + my $result = 0; + my $defaultConfigPath = + "$openslxConfig{'private-path'}/config/stage1/default"; + if (!-e "$defaultConfigPath/rootfs") { + slxsystem("mkdir -p $defaultConfigPath/rootfs"); + $result = 1; + } + return $result; +} + =item B Creates the configuration folder for the system whose name has been given in @@ -135,7 +150,7 @@ sub createConfigFolderForSystem my $result = 0; my $systemConfigPath - = "$openslxConfig{'private-path'}/config/$systemName/default"; + = "$openslxConfig{'private-path'}/config/stage3/$systemName/default"; if (!-e "$systemConfigPath/initramfs") { slxsystem("mkdir -p $systemConfigPath/initramfs"); $result = 1; @@ -147,6 +162,20 @@ sub createConfigFolderForSystem return $result; } +sub createConfigFolderForVendorOS +{ + my $vendorOSName = shift || confess "need to pass in system-name!"; + + my $result = 0; + my $vendorOSConfigPath + = "$openslxConfig{'private-path'}/config/stage1/$vendorOSName"; + if (!-e "$vendorOSConfigPath") { + slxsystem("mkdir -p $vendorOSConfigPath/rootfs"); + $result = 1; + } + return $result; +} + =back =cut -- cgit v1.2.3-55-g7522