Skip navigation

Portable Home Directories and Login Hooks

3439 Views 3 Replies Latest reply: Mar 23, 2011 2:07 PM by jb97392 RSS
Steve Rhyne Level 1 Level 1 (40 points)
Currently Being Moderated
Sep 10, 2010 2:22 PM
We recently switched from Network Home Directories to Portable Home Directories. We used to use login hooks to do all kinds of nifty things to a user's home folder at login, but now it's complicated. I can't figure out at what point in the login+sync process the login hook executes.

If the login hook executes before syncing, then I need to modify the network copy of the home folder, i.e. Network/Servers/servername/.../username. If the login hook executes after syncing, then I need to modify the local copy of the home folder, i.e. /Users/username. Unless I'm mistaken, you can't just use the tilde (~) in the script to denote the path the home folder, so you have to list the path explicitly.

My testing seemed to result in inconsistent behavior. Can anyone give me some guidance?

(Keywords: Loginhook Logouthook Login Script Logout Script Mobility Mobile PHD)
  • Syth Level 1 Level 1 (45 points)
    Currently Being Moderated
    Sep 21, 2010 5:31 PM (in response to Steve Rhyne)
    The first thing to remember, and it's very easy to forget, is that the login and logout hooks are run by root, not by the user. This is why ~ would never work.

    The user name (the short name, that is) is passed to the script in $1

    For example:

    #!/bin/bash

    #Log the User's full name
    _NAME=`dscl . -read /Users/$1 RealName | tail -1`
    logger -t session "** $_NAME logged in."

    #Take a picture
    logger -t session "** imagesnap of $1"
    DATE=`date +%y%m%d%H%M%S`
    SNAP=${1}_${DATE}.jpg
    TEMP=/tmp/snaps
    FILE=${TEMP}/${SNAP}
    mkdir -p $TEMP
    /usr/local/bin/imagesnap ${FILE}

    EOF

    which takes a picture with the iSight whenever any user logs in. If you want to use ~ you will need to use ~${1}/
    MacPro Quad Core, G4 1000bT, MacBookPro, mini server, Mac OS X (10.6.4), 10.6.4 Server on MacPro
  • jb97392 Calculating status...
    Currently Being Moderated
    Mar 23, 2011 2:07 PM (in response to Steve Rhyne)
    Were you able to make any progress in this area? I'm trying to do the same thing now...

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.