From c598592cf9ea258cf8d5c833bd2f9e43feb82307 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 21 Dec 2012 16:50:46 +0100 Subject: add possibility to sync only config files from /config/stage1 w/o the need to clone, update or install. we don't brag about it, yet. --- src/installer/OpenSLX/OSSetup/Engine.pm | 93 +++++++++++++-------------------- src/installer/slxos-setup | 13 +++++ 2 files changed, 48 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/installer/OpenSLX/OSSetup/Engine.pm b/src/installer/OpenSLX/OSSetup/Engine.pm index 07d9c749..2ecceeed 100644 --- a/src/installer/OpenSLX/OSSetup/Engine.pm +++ b/src/installer/OpenSLX/OSSetup/Engine.pm @@ -299,23 +299,8 @@ 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); - } - + $self->configVendorOS(); # add the initramfs rootfs and tools to the stage1 $self->_copyRootfs(); #callInSubprocess( @@ -417,8 +402,27 @@ sub cloneVendorOS # generate default openslx directories for the client $self->_generateDefaultDirs(); - # copy stage1 config ... + $self->configVendorOS(); + # add the initramfs rootfs and tools to the stage1 + $self->_copyRootfs(); + $self->_touchVendorOS(); + $self->addInstalledVendorOSToConfigDB(); + return; +} + +sub configVendorOS +{ + my $self = shift; + my $vendorOSName = $self->{'vendor-os-name'}; + + if (! (-e $self->{'vendor-os-path'})) { + # vendor-os has NOT been installed yet + die _tr("The vendor-OS '%s' does NOT exist yet!\n" . + "Please install or clone the vendor-OS '%s' first.\n", + $vendorOSName, $vendorOSName); + } + # first copy default files ... my $defaultConfigPath = "$openslxConfig{'private-path'}" . "/config/stage1/default/rootfs/"; @@ -428,17 +432,11 @@ sub cloneVendorOS } # ... now pour system-specific configuration on top (if any) ... my $vendorOSConfigPath = "$openslxConfig{'private-path'}/config/stage1/" . - "$self->{'vendor-os-name'}/rootfs/"; + "$vendorOSName/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(); - $self->addInstalledVendorOSToConfigDB(); - return; } sub updateVendorOS @@ -464,23 +462,8 @@ 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->configVendorOS(); $self->_copyRootfs(); $self->_touchVendorOS(); vlog( @@ -1249,6 +1232,10 @@ sub _copyStage1Config my $self = shift; my $source = shift; + my $additionalRsyncOptions = $ENV{SLX_RSYNC_OPTIONS} || ''; + my $rsyncFH; + my $rsyncCmd = "rsync -av --numeric-ids $additionalRsyncOptions" . + " $source $self->{'vendor-os-path'}"; vlog( 0, _tr( @@ -1256,26 +1243,16 @@ sub _copyStage1Config $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, $! - ); - } + or die _tr("unable to start rsync for source '%s', giving up! (%s)", + $source, $!); + print "$rsyncFH\n"; + close($rsyncFH) + or die _tr("unable to copy to target '%s', giving up! (%s)", + $self->{'vendor-os-path'}, $!); + return; } diff --git a/src/installer/slxos-setup b/src/installer/slxos-setup index 30c9287b..acfb3b8d 100755 --- a/src/installer/slxos-setup +++ b/src/installer/slxos-setup @@ -131,6 +131,18 @@ if ($action =~ m[^import]i) { or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); $engine->initialize($vendorOSName, 'clone'); $engine->cloneVendorOS($source); +} elsif ($action =~ m[^config]i) { + my $vendorOSName = shift @ARGV; + if (!defined $vendorOSName) { + print STDERR _tr("You need to specify exactly one vendor-OS-name!\n"); + pod2usage(2); + } + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + $engine->initialize($vendorOSName, 'config'); + $engine->configVendorOS(); } elsif ($action =~ m[^remove]i) { my $vendorOSName = shift @ARGV; if (!defined $vendorOSName) { @@ -178,6 +190,7 @@ if ($action =~ m[^import]i) { sort glob("$openslxConfig{'private-path'}/stage1/*") ); } else { +# config # don't brag about it, yet. vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0)); You need to specify exactly one action: clone -- cgit v1.2.3-55-g7522