#!/bin/sh
#
lookup_local=$(niutil -read . /users/$1 2> /dev/null)
if [ "$lookup_local" != "" ]; then
# this will grab local and mobile users, as they're both strictly 'local' users.
auth_prop=$(niutil -readprop . /users/$1 authentication_authority 2> /dev/null | grep LocalCachedUser)
if [ "$auth_prop" != "" ]; then
# Do your stuff for mobile users here.
logger "LoginHook: Starting for Mobile Account - $1"
else
# Do your stuff for local users here.
logger "LoginHook: Starting for Local Account - $1"
fi
else
# Do your stuff for network users here.
logger "LoginHook: Starting for Network Account - $1"
home_loc=$(dscl /Search -read /Users/$1 homeDirectory | sed 's|dsAttrTypeNative:homeDirectory: ||g')
/bin/mkdir -p /Library/Caches/$1
/usr/sbin/chown $1 /Library/Caches/$1
/usr/bin/sudo -u $1 /bin/chmod 700 /Library/Caches/$1
/usr/bin/sudo -u $1 /bin/rm -rf $home_loc/Library/Caches
/usr/bin/sudo -u $1 /bin/ln -s /Library/Caches/$1 $home_loc/Library/Caches
fi
logger "LoginHook: Finished for - $1"