-
Notifications
You must be signed in to change notification settings - Fork 8
/
installer.sh
41 lines (31 loc) · 1011 Bytes
/
installer.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
#!/usr/bin/env bash
PROJECT_NAME="init-macOS-dev"
SOURCE_URL="https://github.com/zthxxx/${PROJECT_NAME}/raw/master/"
is_command() { command -v $@ &> /dev/null; }
download_init_project() {
if is_command git; then
rm -rf "${PROJECT_NAME}"
git clone "https://github.com/zthxxx/${PROJECT_NAME}.git" || exit 1
cd "$PROJECT_NAME"
else
# macOS Mojave and above need `command line tools` for git
echo '
Please install git at first.
(Usually by `sudo xcode-select --install`)
'
exit 1
fi
}
echo '
+------------------------------+
Initialize macOS
+------------------------------+
'
mkdir -p ~/Downloads
cd ~/Downloads
download_init_project
# make `sudo` no-timeout in a session
sudo perl -i -pe "s/^Defaults\tenv_reset.*/Defaults\tenv_reset, timestamp_timeout=-1/" /etc/sudoers
sudo -i sudo -u $USER -i "`pwd`/init.sh" "`pwd`"
# restore `sudo` timeout to 60s
sudo perl -i -pe "s/^Defaults\tenv_reset.*/Defaults\tenv_reset, timestamp_timeout=60/" /etc/sudoers