Commit 3cf3fa1b authored by Kirk Webb's avatar Kirk Webb
Browse files

Made a couple of enhancements to the linux "prepare" script:

* Now removes process accounting files
* Now removes backup files in /etc (files w/ a ~ or - appended)
parent 982672dd
...@@ -22,6 +22,7 @@ my $MAILFILE = "/var/spool/mail/root"; ...@@ -22,6 +22,7 @@ my $MAILFILE = "/var/spool/mail/root";
my $NTPDRIFT = "/etc/ntp/drift"; my $NTPDRIFT = "/etc/ntp/drift";
my $SFSUSERS = "/etc/sfs/sfs_users"; my $SFSUSERS = "/etc/sfs/sfs_users";
my $SFSHOSTKEY = "/etc/sfs/sfs_host_key"; my $SFSHOSTKEY = "/etc/sfs/sfs_host_key";
my $VARACCTDIR = "/var/account";
# Drag in path stuff so we can find emulab stuff. # Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; } BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
...@@ -112,6 +113,25 @@ while ($dirent = readdir(LOG)) { ...@@ -112,6 +113,25 @@ while ($dirent = readdir(LOG)) {
} }
closedir(LOG); closedir(LOG);
print "Removing accounting files ...\n";
if ( -f "$LOGDIR/pacct" ) {
unlink("$LOGDIR/pacct");
}
opendir(VARACCT,$VARACCTDIR) or
die("Could not open directory $VARACCTDIR: $!");
while ($dirent = readdir(VARACCT)) {
my $file = $VARACCTDIR . "/" . $dirent;
if (-f $file) {
if ($file =~ /acct/) {
unlink($file) or
die ("Could not unlink $file: $!");
}
}
}
closedir(VARACCT);
print "Removing root's history ...\n"; print "Removing root's history ...\n";
if (-f $HISTORY) { if (-f $HISTORY) {
unlink($HISTORY) or unlink($HISTORY) or
...@@ -158,3 +178,19 @@ foreach my $dir (@VARDIRS) { ...@@ -158,3 +178,19 @@ foreach my $dir (@VARDIRS) {
system("rm -rf $VARDIR/$dir/*"); system("rm -rf $VARDIR/$dir/*");
} }
} }
print "Removing backup files in /etc\n";
opendir(ETC,"/etc") or
die ("Couldn't open /etc: $!");
while ($dirent = readdir(ETC)) {
my $file = "/etc/" . $dirent;
if (-f $file) {
if (($file =~ /~$/) || ($file =~ /-$/)) {
unlink($file) or
die ("Couldn't unlink $file: $!");
}
}
}
closedir(ETC);
Supports Markdown
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