Advertisement
themacdweeb

PostOSXUpdate-CleanUpScript.sh

Jan 26th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.76 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # ---------------------------------------------------------------------------
  4. # script intended to address the following after any combo update is run:
  5. # 1. suppress iCloud wizard for all current/future/root users
  6. # 2. suppress bluetooth wizard for all current/future/root users
  7. # 3. Remove the directory causing "local itmes" keychain errors
  8. # ---------------------------------------------------------------------------
  9.  
  10. #--- variables
  11. over500=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`
  12. sw_vers=$(sw_vers -productVersion)
  13. sw_build=$(sw_vers -buildVersion)
  14. Root="/private/var/root"
  15. SetUp="/Library/Preferences/com.apple.SetupAssistant"
  16. Bluetooth="/Library/Preferences/com.apple.Bluetooth"
  17. Log="/Library/Logs/YourOrgLogs/"
  18.  
  19. #--- Set Logging
  20. if [ ! -d "${Log}" ];
  21. then
  22.     mkdir $Log
  23.     chown root:wheel $Log
  24.     chmod 777 $Log
  25. fi
  26. exec >> "${Log}"/PostComboUpdate.log 2>&1
  27.  
  28. #----------------------------------------------------------
  29. #  Timestamp
  30. #----------------------------------------------------------
  31. echo ""
  32. echo ""
  33. echo "###################################"
  34. echo "##### `date "+%A %m/%d/%Y %H:%M"`"
  35. echo "###################################"
  36. echo ""
  37. echo ""
  38.  
  39. # for all future users
  40. for i in "/System/Library/User Template"/*
  41. do
  42.     # stop icloud wizard
  43.     defaults write "${i}"$SetUp DidSeeCloudSetup -bool TRUE
  44.     defaults write "${i}"$SetUp GestureMovieSeen none
  45.     defaults write "${i}"$SetUp LastSeenBuddyBuildVersion "${sw_build}"
  46.     defaults write "${i}"$SetUp LastSeenCloudProductVersion "${sw_vers}"
  47.  
  48.     # stop bluetooth pop-up
  49.     defaults write "${i}"$Bluetooth BluetoothAutoSeekPointingDevice -bool false
  50.     defaults write "${i}"$Bluetooth BluetoothAutoSeekKeyboard -bool false
  51.     echo "The $i user template has been fixed to suppress any iCloud or bluetooth pop-up wizards."
  52. done
  53.  
  54. echo ""
  55. echo ""
  56.  
  57. # for all current users
  58. for i in $over500
  59. do
  60.     if [ ! "${i}" = "Guest" ]; then
  61.  
  62.         if [ -d /Users/"${i}"/Library ]; then
  63.        
  64.             # stop icloud wizard
  65.             defaults write /Users/"${i}"$SetUp DidSeeCloudSetup -bool TRUE
  66.             defaults write /Users/"${i}"$SetUp GestureMovieSeen none
  67.             defaults write /Users/"${i}"$SetUp LastSeenBuddyBuildVersion "${sw_build}"
  68.             defaults write /Users/"${i}"$SetUp LastSeenCloudProductVersion "${sw_vers}"
  69.  
  70.             # stop bluetooth pop-up
  71.             defaults write /Users/"${i}"$Bluetooth BluetoothAutoSeekPointingDevice -bool false
  72.             defaults write /Users/"${i}"$Bluetooth BluetoothAutoSeekKeyboard -bool false
  73.            
  74.             # ensure files have correct ownership:permissions
  75.             chown "${i}":staff /Users/"${i}"$SetUp.plist
  76.             chown "${i}":staff /Users/"${i}"$Bluetooth.plist
  77.  
  78.             # delete problem directory from the keychains folder
  79.             rm -drv /Users/"${i}"/Library/Keychains/********-****
  80.             echo "The $i user account has been fixed to suppress any iCloud, keychain or bluetooth errors on startup."
  81.         fi
  82.     fi
  83. done
  84.  
  85. echo ""
  86. echo ""
  87.  
  88. # for the root user
  89. if [ -d "${Root}"/Library ]; then
  90.  
  91.     # stop icloud wizard
  92.     defaults write "${Root}"$SetUp DidSeeCloudSetup -bool TRUE
  93.     defaults write "${Root}"$SetUp GestureMovieSeen none
  94.     defaults write "${Root}"$SetUp LastSeenBuddyBuildVersion "${sw_build}"
  95.     defaults write "${Root}"$SetUp LastSeenCloudProductVersion "${sw_vers}"
  96.  
  97.     # stop bluetooth pop-up
  98.     defaults write "${Root}"$Bluetooth BluetoothAutoSeekPointingDevice -bool false
  99.     defaults write "${Root}"$Bluetooth BluetoothAutoSeekKeyboard -bool false
  100.        
  101.     # ensure files have correct ownership:permissions
  102.     chown root:wheel "${Root}"$SetUp.plist
  103.     chown root:wheel "${Root}"$Bluetooth.plist
  104.  
  105.     # delete problem directory from the keychains folder
  106.     rm -drv "${Root}"/Keychains/********-****
  107.  
  108.     echo "The root user has been fixed to suppress any iCloud, keychain or bluetooth errors on startup."
  109. fi
  110.  
  111. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement