summaryrefslogtreecommitdiffstats
path: root/installer/OpenSLX/OSExport/FileSystem/NFS.pm
diff options
context:
space:
mode:
authorOliver Tappe2008-07-17 22:12:56 +0200
committerOliver Tappe2008-07-17 22:12:56 +0200
commit8475a6c9dd8ad9e6f079e1df6bb82e8170f12aa2 (patch)
treee1aee5da2524536d9d7d679daef279fa14943b65 /installer/OpenSLX/OSExport/FileSystem/NFS.pm
parent* fixed problem a least one database server (mysql) not being able to start (diff)
downloadcore-8475a6c9dd8ad9e6f079e1df6bb82e8170f12aa2.tar.gz
core-8475a6c9dd8ad9e6f079e1df6bb82e8170f12aa2.tar.xz
core-8475a6c9dd8ad9e6f079e1df6bb82e8170f12aa2.zip
* fixed bad bug that would cause removal of vendor-OS if the export was
faked by bind-mounting to the vendor-OS. Now we simply give the same warning as when faking the export and skip the actuall removal. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1933 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer/OpenSLX/OSExport/FileSystem/NFS.pm')
-rw-r--r--installer/OpenSLX/OSExport/FileSystem/NFS.pm83
1 files changed, 52 insertions, 31 deletions
diff --git a/installer/OpenSLX/OSExport/FileSystem/NFS.pm b/installer/OpenSLX/OSExport/FileSystem/NFS.pm
index b114348d..e034b127 100644
--- a/installer/OpenSLX/OSExport/FileSystem/NFS.pm
+++ b/installer/OpenSLX/OSExport/FileSystem/NFS.pm
@@ -52,37 +52,12 @@ sub exportVendorOS
my $source = shift;
my $target = $self->{'export-path'};
-
- # For development purposes, it is very desirable to be able to take a
- # shortcut that avoids doing the actual copying of the folders (as that
- # takes a considerable amount of time).
- # In order to support this, we explicitly check if the OpenSLX NFS export
- # root folder (/srv/openslx/export/nfs) is a bind-mount of the OpenSLX
- # stage1 folder (/var/opt/openslx/stage1).
- # If that is the case, we print a notice and skip the rsync step (which
- # wouldn't work anyway, as source and target folder are the same).
- my $stage1Root = dirname($source);
- my $nfsRoot = dirname($target);
- chomp(my $canonicalStage1Root = qx{readlink -f $stage1Root} || $stage1Root);
- chomp(my $canonicalNFSRoot = qx{readlink -f $nfsRoot} || $nfsRoot);
- my @mounts = slurpFile('/etc/mtab');
- for my $mount (@mounts) {
- if ($mount =~ m{
- ^
- $canonicalStage1Root # mount source
- \s+
- $canonicalNFSRoot # mount target
- \s+
- none # filesystem for bind mounts is 'none'
- \s+
- \S*\bbind\b\S* # look for bind mounts only
- }gmsx) {
- warn _tr(
- "%s is a bind-mount to vendor-OS root - rsync step is skipped!",
- $target
- );
- return;
- }
+ if ($self->_isTargetBindMounted($source, $target)) {
+ warn _tr(
+ "%s is a bind-mount to vendor-OS root - rsync step is skipped!",
+ $target
+ );
+ return;
}
$self->_copyViaRsync($source, $target);
@@ -94,7 +69,16 @@ sub purgeExport
{
my $self = shift;
+ my $source = $self->{'engine'}->{'vendor-os-path'};
my $target = $self->{'export-path'};
+ if ($self->_isTargetBindMounted($source, $target)) {
+ warn _tr(
+ "%s is a bind-mount to vendor-OS root - removal step is skipped!",
+ $target
+ );
+ return;
+ }
+
if (system("rm -r $target")) {
vlog(0, _tr("unable to remove export '%s'!", $target));
return 0;
@@ -214,4 +198,41 @@ sub _determineIncludeExcludeList
return $includeExcludeList;
}
+sub _isTargetBindMounted
+{
+ my $self = shift;
+ my $source = shift;
+ my $target = shift;
+
+ # For development purposes, it is very desirable to be able to take a
+ # shortcut that avoids doing the actual copying of the folders (as that
+ # takes a considerable amount of time).
+ # In order to support this, we explicitly check if the OpenSLX NFS export
+ # root folder (/srv/openslx/export/nfs) is a bind-mount of the OpenSLX
+ # stage1 folder (/var/opt/openslx/stage1).
+ # If that is the case, we print a notice and skip the rsync step (which
+ # wouldn't work anyway, as source and target folder are the same).
+ my $stage1Root = dirname($source);
+ my $nfsRoot = dirname($target);
+ chomp(my $canonicalStage1Root = qx{readlink -f $stage1Root} || $stage1Root);
+ chomp(my $canonicalNFSRoot = qx{readlink -f $nfsRoot} || $nfsRoot);
+ my @mounts = slurpFile('/etc/mtab');
+ for my $mount (@mounts) {
+ if ($mount =~ m{
+ ^
+ $canonicalStage1Root # mount source
+ \s+
+ $canonicalNFSRoot # mount target
+ \s+
+ none # filesystem for bind mounts is 'none'
+ \s+
+ \S*\bbind\b\S* # look for bind mounts only
+ }gmsx) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
1;