-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·241 lines (197 loc) · 7.59 KB
/
install.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/usr/bin/env bash
#######################################################################################################################################
# macOS 10.15+ (Catalina) Init script to install dependencies
#######################################################################################################################################
eval "$(curl -s -L https://raw.githubusercontent.com/ashtonian/dotfiles/master/lib_sh/echos.sh)"
bot "I am alive."
#######################################################################################################################################
# Sudo
#######################################################################################################################################
# Do we need to ask for sudo password or is it already passwordless?
grep -q 'NOPASSWD: ALL' /etc/sudoers.d/$LOGNAME > /dev/null 2>&1
if [ $? -ne 0 ]; then
# echo "no suder file"
sudo -v
# Keep-alive: update existing sudo time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
bot "Do you want me to setup this machine to allow you to run sudo without a password?\nPlease read here to see what I am doing: http://wiki.summercode.com/sudo_without_a_password_in_mac_os_x"
read -r -p "[y|n]?" response
if [[ $response =~ (yes|y|Y) ]];then
running "enabling passwordless sudo"
if ! grep -q "#includedir /private/etc/sudoers.d" /etc/sudoers; then
echo '#includedir /private/etc/sudoers.d' | sudo tee -a /etc/sudoers > /dev/null
fi
echo -e "Defaults:$LOGNAME !requiretty\n$LOGNAME ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$LOGNAME
# bot "You can now run sudo commands without password!"
print_success
else
ok
fi
fi;
# ###########################################################
# Install non-brew various tools (PRE-BREW Installs)
# ###########################################################
running "ensuring build/install tools are available"
if ! xcode-select --print-path &> /dev/null; then
running "installing tools"
# Prompt user to install the XCode Command Line Tools
xcode-select --install &> /dev/null
# Wait until the XCode Command Line Tools are installed
until xcode-select --print-path &> /dev/null; do
sleep 5
done
print_result $? ' XCode Command Line Tools Installed'
# Prompt user to agree to the terms of the Xcode license
# https://github.com/alrra/dotfiles/issues/10
sudo xcodebuild -license accept
print_result $? 'Agree with the XCode Command Line Tools licence'
else
sudo xcodebuild -license accept
fi;
# ###########################################################
# install homebrew
# ###########################################################
export PATH="$PATH:/opt/homebrew/bin"
running "checking homebrew"
brew_bin=$(which brew) 2>&1 > /dev/null
if [[ $? != 0 ]]; then
running "install homebrew"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
print_success
if [[ $? != 0 ]]; then
error "unable to install homebrew, script $0 abort!"
exit 2
fi
running "brew analytics off"
brew analytics off
print_success
else
print_success
bot "run brew update && upgrade -[y|n]?"
read -r "" response
if [[ $response =~ (y|yes|Y) ]]; then
running "updating homebrew..."
brew update
print_success
running "upgrading brew packages..."
brew upgrade
print_success
else
ok
fi
fi
running "upgrading brew packages..."
# Just to avoid a potential bug
mkdir -p ~/Library/Caches/Homebrew/Formula
brew doctor
print_success
# ###########################################################
# Git Config
# ###########################################################
bot "OK, now I am going to update the .gitconfig for your user info:"
grep 'user = GITHUBUSER' ./homedir/.gitconfig > /dev/null 2>&1
if [[ $? = 0 ]]; then
read -r -p "What is your git username? " githubuser
fullname=`osascript -e "long user name of (system info)"`
if [[ -n "$fullname" ]];then
lastname=$(echo $fullname | awk '{print $2}');
firstname=$(echo $fullname | awk '{print $1}');
fi
if [[ -z $lastname ]]; then
lastname=`dscl . -read /Users/$(whoami) | grep LastName | sed "s/LastName: //"`
fi
if [[ -z $firstname ]]; then
firstname=`dscl . -read /Users/$(whoami) | grep FirstName | sed "s/FirstName: //"`
fi
email=`dscl . -read /Users/$(whoami) | grep EMailAddress | sed "s/EMailAddress: //"`
if [[ ! "$firstname" ]]; then
response='n'
else
echo -e "I see that your full name is $COL_YELLOW$firstname $lastname$COL_RESET"
read -r -p "Is this correct? [Y|n] " response
fi
if [[ $response =~ ^(no|n|N) ]]; then
read -r -p "What is your first name? " firstname
read -r -p "What is your last name? " lastname
fi
fullname="$firstname $lastname"
bot "Great $fullname, "
if [[ ! $email ]]; then
response='n'
else
echo -e "The best I can make out, your email address is $COL_YELLOW$email$COL_RESET"
read -r -p "Is this correct? [Y|n] " response
fi
if [[ $response =~ ^(no|n|N) ]]; then
read -r -p "What is your email? " email
if [[ ! $email ]];then
error "you must provide an email to configure .gitconfig"
exit 1
fi
fi
running "replacing items in .gitconfig with your info ($COL_YELLOW$fullname, $email, $githubuser$COL_RESET)"
# test if gnu-sed or MacOS sed
sed -i "s/GITHUBFULLNAME/$firstname $lastname/" ./homedir/.gitconfig > /dev/null 2>&1 | true
if [[ ${PIPESTATUS[0]} != 0 ]]; then
echo
running "looks like you are using MacOS sed rather than gnu-sed, accommodating"
sed -i '' "s/GITHUBFULLNAME/$firstname $lastname/" ./homedir/.gitconfig
sed -i '' 's/GITHUBEMAIL/'$email'/' ./homedir/.gitconfig
sed -i '' 's/GITHUBUSER/'$githubuser'/' ./homedir/.gitconfig
ok
else
echo
bot "looks like you are already using gnu-sed. woot!"
sed -i 's/GITHUBEMAIL/'$email'/' ./homedir/.gitconfig
sed -i 's/GITHUBUSER/'$githubuser'/' ./homedir/.gitconfig
fi
fi
export DOTDIR="$HOME/.dotfiles"
bot "cloning dotfiles locally"
git clone https://github.com/ashtonian/dotfiles.git $DOTDIR
ok
bot "soft linking makcup file from dotfiles to directory"
ln -s $HOME/.dotfiles/.mackup.cfg $HOME/.mackup.cfg
ok
bot "creating sync directory"
mkdir $HOME/.sync
cd $HOME/.sync
ok
bot "clone iterm dracula theme"
git clone https://github.com/dracula/iterm.git $HOME/.sync/dracula-iterm
ok
bot "download alfred and mackup directory"
bot "NOTE: authenticated github call, with 2fa enabled must use PAT"
## AUTHENTICATED CALL - this only works for me, need to make this more friendly for others.
cd $HOME/.sync
git clone https://github.com/ashtonian/alfred
git clone https://github.com/ashtonian/mackup
ok
bot "download bypass paywall"
cd $HOME/.sync
git clone https://github.com/iamadamdev/bypass-paywalls-chrome.git
ok
bot "download and install colorls dracula theme"
cd $HOME/.sync
git clone https://github.com/dracula/colorls.git
mkdir -p $HOME/.config/colorls
cp $HOME/.sync/colorls/dark_colors.yaml ~/.config/colorls/dark_colors.yaml
ok
bot "download and install iterm dracula theme"
cd $HOME/.sync
git clone https://github.com/dracula/iterm.git
ok
bot "download and install alfred dracula theme"
cd $HOME/.sync
git clone https://github.com/dracula/alfred alfred-dracula
ok
# check ver first then update or install
## don't switch
export RUNZSH=no
export CHSH=no
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
bot "running configure script"
cd $DOTDIR
zsh -c ./config.sh
ok