-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreset_iCloudPrefsPane.sh
More file actions
51 lines (43 loc) · 1.11 KB
/
reset_iCloudPrefsPane.sh
File metadata and controls
51 lines (43 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# Exit upon failed command
# set -e
# Logs
logTime=$(date +%Y-%m-%d:%H:%M:%S)
resetLog="/tmp/pkg_install_$logTime.log"
exec &> >(tee -a "$resetLog")
# Current user
loggedInUser=$(ls -l /dev/console | cut -d " " -f 4)
# Remove iCloud PLISTs
# MobileMeAccounts.plist AKA iCloud Account PLIST
cd /Users/$loggedInUser/Library/Preferences/
if [ ! -f "MobileMeAccounts.plist" ]; then
sudo mv MobileMeAccounts.plist MobileMeAccounts.plist.old
echo "Removed MobileMeAccount.plist"
else
echo "MobileMeAccount.plist not found."
# exit
fi
# com.apple.iCloudHelper
cd /Users/$loggedInUser/Library/Caches/
if [ ! -f "MobileMeAccounts.plist" ]; then
sudo mv com.apple.iCloudHelper com.apple.iCloudHelper.old
echo "Removed com.apple.iCloudHelper"
else
echo "com.apple.iCloudHelper not found."
# exit
fi
# Reset NVRAM
if [ $? -ne 0 ]; then
sudo /usr/sbin/nvram -c
echo "Reset NVRAM successfully."
fi
# Reboot
if [ $? -ne 0 ]; then
echo "Restarting now. Hit CTRL-C to cancel."
sleep 5s
sudo reboot
else
echo "No changes were made. Reboot cancelled."
exit
fi
exit 0