Use of login or logout events

Not applicable

I am writing to get a better idea of how to use login or logout events. Currently I have a script that I want to run at login/logout that removes Acrobat Pro as the default PDF viewer. JSS reports that this script has run quite a few times but I still have users that have yet to trigger the script. These users have restarted (or had it done for them) their machines, and they login afterwards, but they still do not trigger the login hook even though Console reports that JSS is looking for login hooks (or something like that). Any ideas?

Thanks,
Tim Winningham

7 REPLIES 7

donmontalvo
Esteemed Contributor III

$1 should return the username. Hooks run with root rights, but use the variable to specify user.
"Thomas Larkin" <tlarki at kckps.org> wrote:

http://support.apple.com/kb/HT2420

Don

--
https://donmontalvo.com

tlarkin
Honored Contributor

Hey you learn something new every day I suppose. I didn't know that was there, but I do know it hasn't always been there. Apple just sneakily added that in when I wasn't looking. :)

Casper will do the same thing but I believe it uses $3. There is a manual somewhere that explains all of this.

Not applicable

So I have given this a run on a computer I know works every time, and indeed the next time it logged in, it was recorded. Then I tried it on a machine we were having issues with, and I still get no record in JSS, nor result from the script running though I can see stuff like startup which occurred earlier in the day. Any other idea what could be happening?

Tim WInningham
Systems Manager
Math Dept MW-430

tlarkin
Honored Contributor

Look at the jamf log on the local machine having issues, does it give any clues?

Not applicable

Here is an example of the script I am trying to run:
#!/bin/bash
# Written by -------
# See if the LaunchServices LSHandlers key is set
defaults read com.apple.LaunchServices LSHandlers > /dev/null 2>&1

if [ $? -eq 0 ]
then

# get the current LSHandlers defaults=defaults read com.apple.LaunchServices LSHandlers

# write the new LSHandlers, replacing acrobat pro with acrobat reader defaults write com.apple.LaunchServices LSHandlers "'${defaults/com.adobe.acrobat.pro/com.adobe.acrobat.reader}'"
fi

tlarkin
Honored Contributor

Log in/out hooks run as the root user, so if they are modifying any user level stuff the root user's home directory gets modified not the user being logged in.

Can you provide some specific examples of a script or whatever you are using to to this? Casper has a built in switch that will use $3 as the currently logged in user, but only if Casper runs it and only if it runs it as a log in hook.

donmontalvo
Esteemed Contributor III

I remember $3 is used to designate target volume when running scripts during imaging, but that was back when we used NetRestore.
On Dec 16, 2009, at 2:39 PM, Thomas Larkin wrote:

I've learned tons from you and the others on the list (bet'cha didn't know I was picking your brains, did ya? <g>).

Don

--
https://donmontalvo.com