Commit 2e72452c authored by Leigh Stoller's avatar Leigh Stoller

Can't delay any more; remove local home directories, after making really

really sure that it is no longer NFS mounted. With image sharing, leaving
behind home directories results in homdirs being owned by the wrong user.
We could change the boot code to chown the directory, but I think that
option is worse.
parent 0c9990f9
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -69,6 +69,7 @@ $| = 1;
# library and initialize itself.
#
use libsetup;
use liblocsetup;
#
# XXX Elabinelab hack: option to not unmount NFS filesystems.
......@@ -101,18 +102,40 @@ foreach my $dbfile (@DBFILES) {
#
# Attempt to unmount all NFS filesystem if not already unmounted.
# This allows us to clean up /users and /proj. We only do the cleanup if
# if unmount succeeds and even then, we do it in a safe way.
# if unmount succeeds and even then, we do it in a safe way. Well, safe
# as we can, but we really do not want to leave old directories around.
#
if (!$noumount && -e "/share/freebsd") {
if (!$noumount) {
print "Unmounting NFS filesystems ...\n";
# XXX "unmount -t nfs" does not seem to work
if (!system("umount -h fs")) {
#
# Note that this command will not remove anything if the NFS unmounts
# failed (and we didn't catch it) because the directories in question
# will not be empty.
#
system("rmdir /users/* /proj/* /groups/* /scratch/*");
if (!system("umount -at nfs")) {
foreach my $dir ("/users", "/proj", "/groups", "/scratch") {
# Yes, this can happen.
next
if (! -e $dir);
if (!os_islocaldir("$dir/")) {
die("$dir did not unmount; aborting cleanup");
}
opendir(DIR, $dir) or
die("Could not open directory $dir: $!");
while ($dirent = readdir(DIR)) {
next
if ($dirent eq "." || $dirent eq "..");
my $file = $dir . "/" . $dirent;
if (-d $file) {
if (!os_islocaldir("$file")) {
die("$dir did not unmount; aborting cleanup");
}
print "Removing local dir: $file\n";
system("/bin/rm -rf $file\n");
if ($?) {
die("Could not rm -rf $dir/*");
}
}
}
}
} else {
print "Could not determine if NFS filesystems are unmounted, ".
"NOT cleaning up /proj and /users\n";
......
......@@ -74,6 +74,7 @@ $| = 1;
# library and initialize itself.
#
use libsetup;
use liblocsetup;
#
# XXX Elabinelab hack: option to not unmount NFS filesystems.
......@@ -116,15 +117,37 @@ foreach my $dbfile (@DBFILES) {
# This allows us to clean up /users and /proj. We only do the cleanup if
# if unmount succeeds and even then, we do it in a safe way.
#
if (!($noumount || $isvm) && -e "/share/freebsd") {
if (!$noumount) {
print "Unmounting NFS filesystems ...\n";
if (!system("umount -at nfs")) {
#
# Note that this command will not remove anything if the NFS unmounts
# failed (and we didn't catch it) because the directories in question
# will not be empty.
#
system("rmdir /users/* /proj/* /groups/* /scratch/*");
foreach my $dir ("/users", "/proj", "/groups", "/scratch") {
# Yes, this can happen.
next
if (! -e $dir);
if (!os_islocaldir("$dir")) {
die("$dir did not unmount; aborting cleanup");
}
opendir(DIR, $dir) or
die("Could not open directory $dir: $!");
while ($dirent = readdir(DIR)) {
next
if ($dirent eq "." || $dirent eq "..");
my $file = $dir . "/" . $dirent;
if (-d $file) {
if (!os_islocaldir("$file")) {
die("$dir did not unmount; aborting cleanup");
}
print "Removing local dir: $file\n";
system("/bin/rm -rf $file\n");
if ($?) {
die("Could not rm -rf $dir/*");
}
}
}
}
} else {
print "Could not determine if NFS filesystems are unmounted, ".
"NOT cleaning up /proj and /users\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment