[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] Script to flush down the drain files from every user home...



little something i use (modification on original script from ltsp's
default scripts)
to clean the Desktop from redundant files every day.

i initiated all terminal's users to be pc1...pc72
( and so i have them under /home/pc* )

# find all of the subdirectories under /home
#getent passwd | cut -d: -f6 | while read U
ls -d /home/pc* | while read U
do
	# copy new-style Desktop
	if [ -d "$U"/ ]; then
		echo "clearing folder: $U"/Desktop
		ls --ignore='*.desktop' $U/Desktop | while read F
		do
			rm -f $U/Desktop/$F
			echo "removing file: $U/Desktop/$F"
		done
	fi

done

# also, remove data files from /home/pc* users (with special extentions)
find /home/pc* -maxdepth 2 \( -iname '*.mpg' -o -iname '*.avi' -o
-iname '*.wmv' -o -iname '*.exe' -o -iname '*.mpeg' -o -iname '*.rar'
-o -iname '*.mov' -o -iname '*.ram' -o -iname '*.ppt' -o -iname
'*.xls' -o -iname '*.doc'  -o -iname '*.od?'  \) -print0 | xargs
--no-run-if-empty --null rm -vf

:-)


On Sat, Jun 21, 2008 at 7:20 PM, Les Mikesell <lesmikesell gmail com> wrote:
> James P. Kinney III wrote:
>>
>> On Thu, 2008-06-19 at 20:48 -0700, Jim Christiansen wrote:
>>>
>>> Hi guys,  Thanks the thoughts.  On the upgrade/wipe-install question.
>>> Today I backed up the group, shadow, password bla bla bla bla bla
>>> files, unplugged the back-up rsync drive and did a full wipe then new
>>> k12el5 install.  Put back the vital parts of the necessary conf files,
>>> altered the network settings in the template ltsp dir for my different
>>> network subnet, did the k12 initialize, plugged in the second drive,
>>> mounted it then rsynced back to the users homes and perms of the
>>> users...
>>>
>>> Everything is good to go for the fall start of school!  Now for the
>>> other two boxes!
>>>
>>> OK so. what I need to do is to drop into EVERY users' home and remove
>>> a set of files...
>>>
>>> I've search high and low, through the lists going back 3 years or so
>>> and can't find reference to any script that did this.  I think there
>>> was one that several contributed to that we used to trash the dot
>>> mozilla, .g* files, and I used it also for getting rid of the dot
>>> cxoffice folders.  I'm not great at shell scripts.
>>>
>>> Anyone have one?  Thanks,   Jim  :-)
>>
>> for users in `ls -1 /home`
>> do
>> cd /home/$user
>> rm -rf .mozilla .g* .cxoffice*
>> done
>>
>> Just add more dotfiles to the list. This is a very aggressive script and
>> it will not spare any users. Make sure you have a backup of /home first.
>
> I think as-is, that would delete all of the home folders since it sets the
> variable "users" and uses "user" which will be empty.   Also you don't want
> the extra stuff from -l in your ls listing and you probably want to make
> sure the cd succeeded before removing anything.
>
> --
>  Les Mikesell
>   lesmikesell gmail com
>
> _______________________________________________
> K12OSN mailing list
> K12OSN redhat com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]