Advertisement
Guest User

LoginHook for freezing OS X network accounts

a guest
Jul 30th, 2013
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3.  
  4. lookup_local=$(niutil -read . /users/$1 2> /dev/null)
  5.  
  6. if [ "$lookup_local" != "" ]; then
  7. # this will grab local and mobile users, as they're both strictly 'local' users.
  8. auth_prop=$(niutil -readprop . /users/$1 authentication_authority 2> /dev/null | grep LocalCachedUser)
  9. if [ "$auth_prop" != "" ]; then
  10. # Do your stuff for mobile users here.
  11. logger "LoginHook: Starting for Mobile Account - $1"
  12. else
  13. # Do your stuff for local users here.
  14. logger "LoginHook: Starting for Local Account - $1"
  15. fi
  16. else
  17. # Do your stuff for network users here.
  18. logger "LoginHook: Starting for Network Account - $1"
  19. home_loc=$(dscl /Search -read /Users/$1 homeDirectory | sed 's|dsAttrTypeNative:homeDirectory: ||g')
  20. /bin/mkdir -p /Library/Caches/$1
  21. /usr/sbin/chown $1 /Library/Caches/$1
  22. /usr/bin/sudo -u $1 /bin/chmod 700 /Library/Caches/$1
  23. /usr/bin/sudo -u $1 /bin/rm -rf $home_loc/Library/Caches
  24. /usr/bin/sudo -u $1 /bin/ln -s /Library/Caches/$1 $home_loc/Library/Caches
  25. fi
  26.  
  27. logger "LoginHook: Finished for - $1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement