[Casper] Flushing User Caches
Thomas Larkin
tlarki at kckps.org
Wed Jan 21 14:20:08 PST 2009
I just like using loops because I can change the rm -rf command to ls
-al for testing purposes and I don't have to rewrite a bunch of lines of
code, and I can use a large list of file paths. That way nothing is
harmed. Also, when working in home directories users can change things
around, so sometimes I use if and the touch command so if they rename
the file, then I create it, if the file exists then I delete it.
I have had users rename files for only god knows why in their home
directory. Luckily none of my users by default have terminal access.
Your method works out fine as well, it is purely a preference thing. I
sometimes also like to add a bit of chatting to my scripts so logs tell
me what they do, also a preference.
___________________________
Thomas Larkin
TIS Department
KCKPS USD500
tlarki at kckps.org
blackberry: 913-449-7589
office: 913-627-0351
>>> Miles Leacy <miles.leacy at themacadmin.com> 01/21/09 4:11 PM >>>
When you run a script via a Casper policy, $3 = the user's shortname.
This
is why I structure my commands to target /Users/$3/
This may be a matter of preference, but I would skip the $file variable
and
the for loop in this case. We're operating on known values. To me,
at
least, it seems unnecessary to declare $file and then set up a for/if
structure when we can just operate on each item and save lines.
The script below accomplishes the goal with just a few lines and is set
up
to be run as part of a Casper policy triggered by login.
## Start script
#!/bin/bash
m -Rf /Users/$3/Library/Cookies/*
m -Rf /Users/$3/Library/Safari/*
rm -Rf /Users/$3/Library/Caches/Metadata/Safari/*
rm -f /Users/$3/Library/Preferences/com.apple.Safari.plist
rm -f /Users/$3/Library/Preferences/com.apple.Safari.RSS.plist
## End script
I save "for" loops for situations where you need to discover the item
to act
upon, i.e.
for i in $( dscl . -read /Groups/admin| grep GroupMembership:| awk
'{for (j=3;
j<=NF; j++) printf " %s", $j; printf "\n" }' )
to get a list of all members of the admin group, other than root.
----------
Miles A. Leacy IV
Certified System Administrator 10.4
Certified Technical Coordinator 10.5
Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com
On Wed, Jan 21, 2009 at 4:53 PM, Thomas Larkin <tlarki at kckps.org>
wrote:
> Forgot to mention, this is written as a log in hook, so the it will
pull
> the current user's home directory. If you run it otherwise it won't
> work as it will look for root's home since it will be running most
> likely as root.
>
>
> ___________________________
> Thomas Larkin
> TIS Department
> KCKPS USD500
> tlarki at kckps.org
> blackberry: 913-449-7589
> office: 913-627-0351
>
>
>
>
>
> >>> Miles Leacy <miles.leacy at themacadmin.com> 01/21/09 3:30 PM >>>
> I see two problems with your script...
>
> 1. I don't believe "~" will work in your script since it's run by
root.
> I
> use the Casper variables to indicate "the home folder of the account
> logged
> in (or being logged in). See my commands below.
> 2. If your clients are Leopard clients, you won't find anything at
> ~/Library/Caches/Safari/. See below for the locations to be
concerned
> with.
>
> If you want to emulate the "Reset Safari" menu item put this in your
> script
> instead:
>
> m -Rf /Users/$3/Library/Cookies/*
> m -Rf /Users/$3/Library/Safari/*
> rm -Rf /Users/$3/Library/Caches/Metadata/Safari/*
> rm -f /Users/$3/Library/Preferences/com.apple.Safari.plist
> rm -f /Users/$3/Library/Preferences/com.apple.Safari.RSS.plist
>
> You will, of course, need to reset any preferences you did want in
> there
> such as a default home page. You can do this with "defaults write"
or
> "PlistBuddy" at the end of your script.
>
> ----------
> Miles A. Leacy IV
>
> Certified System Administrator 10.4
> Certified Technical Coordinator 10.5
> Certified Trainer
> Certified Casper Administrator
> ----------
> voice: 1-347-277-7321
> miles.leacy at themacadmin.com
> www.themacadmin.com
>
>
>
>
> On Wed, Jan 21, 2009 at 3:58 PM, Gene Anderson
<ganderson at phrd.ab.ca>
> wrote:
>
> > "Thomas Larkin" <tlarki at kckps.org> writes:
> > >What you can do is have a policy set for log in via JSS web front
> end and
> > have it execute the script. Can you post your script?
> >
> > rm -Rf ~/Library/Caches/Safari/*
> >
> > > I assume removing the temp and cache files the application will
> create
> > new ones upon next launch, and they are stored in that user's home
> > directory.
> >
> > yes. I'm mostly interested in the Safari cache.
> >
> > >So you can wild card or loop it for user's that are located in
> /Users and
> > exclude shared if need be.
> >
> > Casper policy is set to execute on login, frequency ongoing, scope
> for all
> > desired machines, and the script is specified in the Scripts tab.
> >
> > Do I have to specify any of the extra paramter options?
> >
> >
> >
> > Gene Anderson
> > Systems Analyst, ACTC, MCP
> > Pembina Hills Regional Division No.7
> > Phone: (780) 674-8535 ext 6860
> > email: ganderson at phrd.ab.ca
> >
> > "Passwords are like bubble gum, strongest when fresh, should never
> be
> > used by groups and create a sticky mess when left laying around"
> >
> > -anon
> >
> >
> > _______________________________________________
> > Casper mailing list
> > Casper at list.jamfsoftware.com
> > http://list.jamfsoftware.com/mailman/listinfo/casper
> >
>
>
More information about the Casper
mailing list