-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorgi.sh
executable file
·211 lines (154 loc) · 5.47 KB
/
corgi.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
#!/usr/bin/env bash
main() {
##run script with sudo.
# if [[ $UID != 0 ]];then
# echo "Please start the script as root ot sudo!"
# exit 1
# fi
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
cur_dir=$PWD
home_dir=$HOME
user=`printf ${home_dir}|awk -F "/" '{print $(split($0, a))}'`
corgi_dir=${home_dir}/.corgi_repository
corgi_rc_file=${home_dir}/.corgi_rc
mkdir -p ${corgi_dir}
mkdir -p ${corgi_rc_file}
sudo rm /var/lib/apt/lists/lock
sudo rm /var/lib/dpkg/lock
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install wget -y
sudo apt-get install curl -y
##install vim
sudo apt-get install vim -y
##install zsh
##see http://ohmyz.sh/
sudo apt-get install zsh -y
zsh_install_file="zsh_install.sh"
wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O "${corgi_dir}/${zsh_install_file}"
cd ${corgi_dir}
sed -i 's/env zsh//g' ${zsh_install_file}
chmod u+x ${zsh_install_file}
sh ${zsh_install_file}
cd -
##install tmux
sudo apt-get install tmux -y
##install git
##ubuntu 14.04
sudo apt-get install software-properties-common -y
sudo apt-add-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version
##install teamviewer
is_install=`dpkg -l teamviewer 2>&1 > /dev/null`
if [ ! $? -eq 0 ];then
if [ `uname -m` == "x86_64" ];then
teamviewer_deb="teamviewer_amd64.deb"
else
teamviewer_deb="teamviewer_i386.deb"
fi
wget https://download.teamviewer.com/download/${teamviewer_deb} -P ${corgi_dir}&& \
sudo dpkg -i ${corgi_dir}/${teamviewer_deb} && apt-get install -f
if [ ! $? -eq 0 ];then
printf "${RED}teamviewer install failed, please install later...${NORMAL}\n"
else
printf "${GREEN}teamviewer install success...${NORMAL}\n"
fi
else
printf "${YELLOW}teamviwer exists...${NORMAL}\n"
fi
##install oracle jdk
##see http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
is_install=`java -version 2>&1 |grep -c "1.8"`
if [ ! ${is_install} -gt 0 ];then
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer -y
sudo apt-get install oracle-java8-set-default -y
result=`java -version 2>&1 |grep -c "1.8"`
if [ ${result} -gt 0 ];then
printf "${GREEN}oracle jdk install success...${NORMAL}\n"
else
printf "${RED}oracle jdk install failed, please install later...${NORMAL}\n"
fi
else
printf "${YELLOW}oracle jdk exists...${NORMAL}\n"
fi
#chsh -s $(grep /bash /etc/shells|tail -1)
#echo $SHELL
##install maven
result=`mvn -v 2>&1 > /dev/null`
if [ ! $? -eq 0 ]; then
maven_package="apache-maven-3.5.2-bin.tar.gz"
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz -P ${corgi_dir}
sudo tar -zxvf ${corgi_dir}/${maven_package} -C /usr/local > /dev/null
cd /usr/local
sudo ln -s apache-maven-3.5.2 maven
cd -
echo -e 'MAVEN_HOME=/usr/local/maven\nPATH=${MAVEN_HOME}/bin:${PATH}' >> ${corgi_rc_file}
printf "${GREEN}maven install success...${NORMAL}\n"
else
printf "${YELLOW}maven exists...${NORMAL}\n"
fi
##install chromium-browser
sudo apt-get install chromium-browser -y
##install gradle 3.4.1
wget https://services.gradle.org/distributions/gradle-3.4.1-bin.zip
sudo mkdir -p /opt/gradle
sudo unzip -d /opt/gradle gradle-3.4.1-bin.zip
echo 'PATH=${PATH}:/opt/gradle/gradle-3.4.1/bin' >> ${corgi_rc_file}
source ${corgi_rc_file}
if [[ `gradle -v | grep -c "Build time"` -eq 1 ]];then
printf "${GREEN}gradle install success......${NORMAL}\n"
else
printf "${YELLOW}gradle install failed......${NORMAL}\n"
fi
#############################################################################
##ending...
#############################################################################
sudo rm -r ${corgi_dir}
chown -R ${user}:${user} ${home_dir}/.zsh*
chown -R ${user}:${user} ${home_dir}/.oh-my-zsh
chown -R ${user}:${user} ${corgi_rc_file}
echo "source ${corgi_rc_file}" >> ${home_dir}/.bashrc
echo "source ${corgi_rc_file}" >> ${home_dir}/.zshrc
echo "${BLUE}corgi init finished...${NORMAL}${GREEN}"
echo " .c.
.:,. :l:.
'olcc,. coc:
,oolcc;:c:;ll'
'lol:codxlcxd
:ollookOd;ld;.,,
:lcllllc....;kx.
.c:cc:;.......
.;.......,..
...,',;;:cccc,....:.
.,:c:::::::::::::c;.....
.,::::::::::::::::::c...'.
::::::llc:;;ccc::c:c:.;c.
:::::::co...''.;..''.:;'
:lc:::cclco; .,....:..
:olloc;.;;'. .,..;;''
.''. . . .. ${NORMAL}"
## use oh-my-zsh
env zsh
}
main