Want more features on Pastebin? Sign Up, it's FREE!
Guest

LoginHook for freezing OS X network accounts

By: a guest on Jul 30th, 2013  |  syntax: None  |  size: 1.01 KB  |  views: 337  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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"
clone this paste RAW Paste Data