| Category: | System Utilities |
| Author/Contact Info | Chris Monahan aka 'Maze' ForeverWatcher@googlemail.com |
| Description: | this little script assumes that you have a /home/guest directory and a /home/default directory it cleans out the /home/guest directory and saves the content of various directories under a time-stamped folder, it then mirrors the /home/default directory in the /home/guest and sets the appropriate modes,uid's and gid's. |
#!/usr/bin/perl
#reguest.pl
#by Chris Monahan
#this is free software, you can distribute it under the same terms as
+perl itself
use warnings;
use strict;
my @dirs = ("Music", "Pictures", "Documents", "Desktop");
print "preserving guest content under a timestamped folder \n \n";
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdist) =
gmtime(time);
$min++;
$hour++;
$mday++;
$sec++;
$mon++;
$year++;
my $count = 0;
my @mkdir = ( "$year:$mon:$mday", "$hour:$min:$sec");
chdir ("/home/guest-content");
while ($count ne @mkdir){
system "mkdir $mkdir[$count]";
chdir "$mkdir[$count]";
$count ++;
}
chdir ("/home");
$count = 0;
while ($count ne @dirs){
my $dest = "guest-content/$year:$mon:$mday/$hour:$min:$sec/";
#unless (
system ("mv guest/$dirs[$count]/ $dest"
)
;
#){
#}
$count++;
}
print "purging configuration settings \n ";
system ("rm -R guest");
print "restoring guest home \n ";
system ("mkdir guest");
system ("cp -R default/* guest");
$count = 0;
while ($count ne @dirs){
system ("mkdir guest/$dirs[$count]");
$count++;
}
print "restoring guest account password and ownership details \n";
#system("usermod -p password guest");
system ("chown -R guest:guest guest");
print "done \n"
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Guest Cleanup
by jdporter (Paladin) on Oct 01, 2006 at 14:09 UTC | |
by ysth (Canon) on Oct 01, 2006 at 17:32 UTC | |
by jdporter (Paladin) on Oct 02, 2006 at 13:28 UTC | |
|
Re: Guest Cleanup
by jwkrahn (Abbot) on Oct 02, 2006 at 00:23 UTC | |
|
Re: Guest Cleanup
by Maze (Sexton) on Oct 04, 2006 at 22:50 UTC |