forked from MoeClub/Note
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MacInitial.sh
161 lines (126 loc) · 4.14 KB
/
MacInitial.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
if [ -f "/usr/bin/sudo" ]; then
#Unload System Daemons
echo "Unload System Daemons ..."
[ "$(sudo whoami)" == "root" ] || return
# System setting
sudo defaults write com.apple.loginwindow TALLogoutSavesState -bool FALSE
sudo defaults write com.apple.loginwindow SHOWOTHERUSERS_MANAGED -bool FALSE
cd "/Volumes/$(ls -1 /Volumes|head -n1)/System/Library/LaunchDaemons"
# I don't have Apple TV so disable AirPlay
sudo launchctl unload -wF com.apple.AirPlayXPCHelper.plist
# Disable apple software updates
sudo launchctl unload -wF com.apple.softwareupdate*
# Disable DVD
sudo launchctl unload -wF com.apple.dvdplayback.setregion.plist
# Disable feedback
sudo launchctl unload -wF com.apple.SubmitDiagInfo.plist
sudo launchctl unload -wF com.apple.CrashReporterSupportHelper.plist
sudo launchctl unload -wF com.apple.ReportCrash.Root.plist
sudo launchctl unload -wF com.apple.GameController.gamecontrollerd.plist
# Disable FTP
sudo launchctl unload -wF com.apple.ftp-proxy.plist
# Disable spindump
sudo launchctl unload -wF com.apple.spindump.plist
sudo launchctl unload -wF com.apple.metadata.mds.spindump.plist
fi
status=`csrutil status |cut -d":" -f2 |grep -io "enable\|disable"`
[ "$status" != "disable" ] && "Please disable SIP. (csrutil disable)" && exit 1
if [ -f "/usr/bin/sudo" ]; then
sudo mount -uw /
[ $? -ne 0 ] && echo "Mount / fail." && exit 1
else
mount -uw /
[ $? -ne 0 ] && echo "Mount / fail." && exit 1
fi
RENAME(){
[ -n "$1" ] || return
for item in `find . -type f -maxdepth 1 -name "$1"`
do
[ -n "$item" ] || continue
echo "$item" |grep -q "\.bak$"
[ $? -eq 0 ] && continue
echo "${item} --> ${item}.bak"
if [ -f "/usr/bin/sudo" ]; then
sudo mv "${item}" "${item}.bak"
else
mv "${item}" "${item}.bak"
fi
done
}
RENAMEBIN(){
[ -f "/usr/bin/sudo" ] && [ -n "$1" ] && [ -f "$1" ] || return
if [ ! -f "${1}.bak" ]; then
echo "${1} --> ${1}.bak"
sudo mv "${1}" "${1}.bak"
fi
if [ -f "${1}.bak" ]; then
sudo ln -sf /usr/bin/true "$1"
fi
}
RENAMERESTORE(){
for item in `find . -type f -maxdepth 1 -name "*.bak"`
do
echo "$item" |grep -q "\.bak$"
[ $? -eq 0 ] || continue
newItem=`echo "${item}" |sed "s/.\bak$//"`
echo "${item} --> ${newItem}"
if [ -f "/usr/bin/sudo" ]; then
sudo mv "${item}" "${newItem}"
else
mv "${item}" "${newItem}"
fi
done
}
RMAPP(){
[ -n "$1" ] && [ -d "$1" ] || return
echo "RM '$1'" && rm -rf "$1"
}
## Unload System Agents
echo "Unload System Agents ..."
cd "/Volumes/$(ls -1 /Volumes|head -n1)/System/Library/LaunchAgents"
# Restore all .bak file
# RENAMERESTORE
# Disable AddressBook and Calendar
RENAME "com.apple.AddressBook*"
RENAME "com.apple.CalendarAgent.plist"
# iCloud
RENAME "com.apple.iCloudUserNotifications.plist"
RENAME "com.apple.icloud.fmfd.plist"
RENAME "com.apple.cloud*"
# Disable imclient (Facetime) and smth else
RENAME "com.apple.imagent.plist"
RENAME "com.apple.IMLoggingAgent.plist"
# spindump (see also code below)
RENAME "com.apple.spindump_agent.plist"
RENAMEBIN "/usr/sbin/spindump"
# Safari is not the only browser in the world
RENAME "com.apple.safaridavclient.plist"
RENAME "com.apple.SafariNotificationAgent.plist"
# in future versions of OS X
RENAME "com.apple.SafariCloudHistoryPushAgent.plist"
# Explain these
RENAME "com.apple.AirPlayUIAgent.plist"
RENAME "com.apple.AirPortBaseStationAgent.plist"
RENAME "com.apple.gamed.plist"
RENAME "com.apple.parentalcontrols.check.plist"
RENAME "com.apple.soagent.plist"
RENAME "com.apple.SocialPushAgent.plist"
RENAME "com.apple.DictationIM.plist"
RENAME "com.apple.Maps.pushdaemon.plist"
RENAME "com.apple.java.updateSharing.plist"
RENAME "com.apple.appstoreupdateagent.plist"
RENAME "com.apple.softwareupdate_notify_agent.plist"
RENAME "com.apple.ScreenReaderUIServer.plist"
RENAME "com.apple.speech.*"
# Remove System APP
echo "Remove System APP ..."
cd "/Volumes/$(ls -1 /Volumes|head -n1)/System/Applications"
RMAPP "TV.app"
RMAPP "News.app"
RMAPP "Home.app"
RMAPP "Books.app"
RMAPP "Chess.app"
RMAPP "Podcasts.app"
RMAPP "Stocks.app"
RMAPP "Music.app"