-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall-osx-python.sh
177 lines (137 loc) · 4.16 KB
/
install-osx-python.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
#!/bin/bash
#
# This scripts installs the following:
# bootstrap
# prepareOS
# brew
# brewCTF
# osx
# anaconda
export LIMITLESS_GITPATH="https://github.com/limitlessv/osx-dev-setup.git"
if [ -z ${LIMITLESS_HOME} ];
then
export LIMITLESS_HOME="$HOME/.LimitlessV"
fi
export TARIKH=`/bin/date +%Y%m%d%H%M%S`
export LIMITLESS_HOME_OLD="$HOME/.LimitlessV.${TARIKH}"
export LIMITLESS_BACKUP="$HOME/.LimitlessV.${TARIKH}/backup"
runme() {
cmd=$*
echo "$cmd"
$cmd
ret=$?
if [[ ${ret} != 0 ]]; then
echo " "
echo "ERROR: Return value non-zero for: $cmd"
echo " "
exit 1
fi
}
download_repository() {
if [ -d ${LIMITLESS_HOME} ]; then
# Saving current setting
mv ${LIMITLESS_HOME} ${LIMITLESS_HOME_OLD}
mkdir -p ${LIMITLESS_HOME}
echo " "
echo "Renamed directory ${LIMITLESS_HOME} to ${LIMITLESS_HOME_OLD}"
echo "You may want to check and delete this directory if not required."
echo "Old .dotfiles will be saved to ${LIMITLESS_HOME_OLD}"
echo " "
sleep ${SLEEP_TIME}
else
# Saving current setting
echo "Old .dotfiles will be saved to ${LIMITLESS_HOME_OLD}"
mkdir -p ${LIMITLESS_HOME_OLD}
fi
echo " "
echo "LIMITLESS GIT Path = ${LIMITLESS_GITPATH}"
echo " "
sleep ${SLEEP_TIME}
runme git clone ${LIMITLESS_GITPATH} ${LIMITLESS_HOME} --recursive
cd ${LIMITLESS_HOME}
echo " "
}
make_backup_files() {
bk_dir_list=(.vim init anaconda1 anaconda3 .pip .ipython)
bk_file_list=(.aliases .bash_profile .bash_prompt .bashrc .curlrc .editorconfig .exports .extra .functions .gitconfig .gitignore .gvimrc .hushlogin .inputrc .path .screenrc .vimrc .wgetrc)
if [ -d ${LIMITLESS_BACKUP} ]; then
echo "Backup will be store in: "$(LIMITLESS_BACKUP)
else
echo 'Create Backup directory: '$LIMITLESS_BACKUP
mkdir -p ${LIMITLESS_BACKUP}
fi
for i in "${bk_dir_list[@]}"
do
if [ -d $HOME/$i ]; then
echo 'Backup: ['$HOME/$i'] to '$LIMITLESS_BACKUP/$i ;
cp -frpv $HOME/$i $LIMITLESS_BACKUP/$i;
else
echo $HOME/$i' Ignored';
fi;
done
for i in "${bk_file_list[@]}"
do
if [ -f $HOME/$i ]; then
echo 'Backup: ['$HOME/$i'] to '$LIMITLESS_BACKUP/$i ;
cp -fpv $HOME/$i $LIMITLESS_BACKUP/$i;
else
echo $HOME/$i' Ignored';
fi;
done
}
function doIt() {
rsync --exclude ".git/" --exclude ".DS_Store" --exclude "bootstrap.sh" \
--exclude "README.md" --exclude "LICENSE" --exclude ".idea/" -avh --no-perms . ~;
source ~/.bash_profile;
}
echo "+---------------------------------------------------------+"
echo "| Step 01.01: Ask for the administrator password upfront. | "
echo "+---------------------------------------------------------+"
sudo -v
# Keep-alive: update existing `sudo` time stamp until `osxprep.sh` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
echo "BEGIN: Updating OSX"
sudo softwareupdate -ia --verbose
echo "END: If this requires a restart, run the script again."
# Install only recommended available updates
#sudo softwareupdate -irv
echo "BEGIN: Installing Xcode Command Line Tools."
# Install Xcode command line tools
xcode-select --install
echo "END: If this requires a restart, run the script again."
echo "BEGIN: If xcode-select: already installed, we are using \"Software Update.\""
sudo softwareupdate --install -a --verbose
echo "END: If this requires a restart, run the script again."
echo "BEGIN: backup"
make_backup_files
echo $LIMITLESS_HOME
if [ ! -d "$LIMITLESS_HOME" ]; then
mkdir -p ${LIMITLESS_HOME}
fi
cd $LIMITLESS_HOME
echo "END: backup"
echo "BEGIN: Download repository"
download_repository
echo "END: Download repository"
echo "BEGIN: sync"
cd bootstrap
if [ "$1" == "--force" -o "$1" == "-f" ]; then
doIt;
else
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
echo "";
if [[ $REPLY =~ ^[Yy]$ ]]; then
doIt;
fi;
fi;
cd ..
echo "END: sync"
echo "BEGIN: brew"
source homebrew/brew-group-permissions.sh
source homebrew/brew.sh
source homebrew/brew-CTF.sh
echo "END: brew"
unset runme;
unset download_repository;
unset make_backup_files;
unset doIt;