Script to move into each home and delete all .g* folders
Harry Sweet
hsweet at gcsny.org
Wed Nov 11 02:41:55 GMT 2009
I had a similar issue (had to replace all my users .mozilla folders) and
wrote this perl script. It could be adapted pretty quickly to do most anything to all users.
This bit parses the /etc/passwd file to get a list of all users
-----------------------------------
open (MYFILE, "/etc/passwd") || die "Problem reading file $!";
my @contents=<MYFILE>;
close (MYFILE);
foreach my $user(@contents){
my @users=split(/:/, $user);
my ($username, $password,$uid, $gid,$gecos, $home, $shell)=@users;
-----------------------
Then the system function can run any terminal command
system("mv $home/.mozilla $home/.mozillaold"); or whatever.
how about
system("rm -rf .g*");
Probably overkill for something you can do from command line, but it might be useful to other
folks even to generate a list of user info
foreach my $user(@contents){
my @users=split(/:/, $user);
my ($username, $password,$uid, $gid,$gecos, $home, $shell)=@users;
print "Name | $username | Home Folder | $home";
}
and so on.
***************************************************reskel.pl**********************************************
#!/usr/bin/perl -w
use strict;
use File::Copy::Recursive qw(dircopy);
my $fromdir = qw (/etc/skel);
open (MYFILE, "/etc/passwd") || die "Problem reading file $!";
my @contents=<MYFILE>;
close (MYFILE);
foreach my $user(@contents){
my @users=split(/:/, $user);
my ($username, $password,$uid, $gid,$gecos, $home, $shell)=@users;
if ($uid > 1001 && -d $home){
print system("mv $home/.mozilla $home/.mozillaold");
system ("rm -r $home/.mozillaold");
print " Copying UserID $uid Group ID $gid to $home. \n";
dircopy($fromdir, $home) or die("$!\n");
system("chown -R $uid:$gid $home");
system ("rm -r $home/.mozillaold");
}
}
>>> Jim Christiansen <jim.c.christiansen at gmail.com> 11/10/09 4:29 PM >>>
OK, it looks like I've settled on Ubuntu 9.04 for our new/old- rehabbed LTSP
server.
I'm symlinking my old K12LTSP rsynced home from another drive into the file
system as the home.
My student homes from the K12LTSPEL5 system are full of all of the wrong
.gconf ... .gnome folders. On startup if they don't exist they are created
no prob. What I need to do is find a script that will:
cd into each student home
rm -rf .g*
cd back out
cd into the next student home and repeat all the way through the home dir
I'm not having any troubles with the authenticating I don't think. I've
appended the old user lines from the k12ltsp group, password and shadow
files into the new ones. My rsynced student homes have ownership and other
permissions preserved.
I think it should all work if it wasn't for all of the old gnome/gconf junk.
Ideas for the script??
Thanks, Jim
More information about the edubuntu-users
mailing list