-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·263 lines (209 loc) · 6.61 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#! /bin/bash
read -p "Enter you sudo password: " -s PASSWORD
#######################################################################
# Path
#######################################################################
CURRENT_PATH="$(pwd)"
cd ~
HOME_PATH="$(pwd)"
HOSTS_PATH="$CURRENT_PATH/hosts"
TAR_GZ_PATH="$CURRENT_PATH/tars"
DEB_PATH="$CURRENT_PATH/debs"
LOG_PATH="$CURRENT_PATH/logs"
SCRIPT_PATH="$CURRENT_PATH/scripts"
# APP
JAVA_PATH="$HOME_PATH/JDK"
ANDROID_PATH="$HOME_PATH/Android"
HEXO_PATH="$HOME_PATH/Hexo"
IDEA_PATH="$HOME_PATH/Idea"
PYCHARM_PATH="$HOME_PATH/Pycharm"
WECHAT_PATH="$HOME_PATH/Wechat"
INODE_PATH="$HOME_PATH/iNode"
#######################################################################
# Declare some common method
#######################################################################
function error()
{
echo "[ERROR]: $1"
echo "$1">>$LOG_PATH/install-log
}
#######################################################################
# Check or make the folder
#######################################################################
cd $CURRENT_PATH
if [ ! -x $LOG_PATH ]; then
mkdir $LOG_PATH
fi
if [ ! -x $DEB_PATH ]; then
error 'Cannot install without deb packages'
exit 1
fi
if [ ! -x "$JAVA_PATH" ]; then
mkdir $JAVA_PATH
fi
if [ ! -x "$ANDROID_PATH" ]; then
mkdir $ANDROID_PATH
fi
if [ ! -x "$IDEA_PATH" ]; then
mkdir $IDEA_PATH
fi
if [ ! -x "$PYCHARM_PATH" ]; then
mkdir $PYCHARM_PATH
fi
if [ ! -x "$WECHAT_PATH" ]; then
mkdir $WECHAT_PATH
fi
if [ ! -x "$INODE_PATH" ]; then
mkdir $INODE_PATH
fi
touch $LOG_PATH/install-log
# exec 2>$LOG_PATH/install-log
#######################################################################
# Update and Upgrade
#######################################################################
echo "$PASSWORD" | sudo -S apt-get update
echo "$PASSWORD" | sudo -S apt-get upgrade -y
#######################################################################
# Install personal app
#######################################################################
# Wiznote
echo -ne '\n' | sudo add-apt-repository ppa:wiznote-team
# Docky
echo -ne '\n' | sudo add-apt-repository ppa:ricotz/docky
# Ultra-flat-icons
echo -ne '\n' | sudo add-apt-repository ppa:noobslab/icons
# Codeblocks
echo -ne '\n' | sudo add-apt-repository ppa:damien-moore/codeblocks-stable
# Indicator-sysmonitor
echo -ne '\n' | sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor
echo "$PASSWORD" | sudo -S apt-get update
echo "$PASSWORD" | sudo -S apt-get install wiznote docky ultra-flat-icons ultra-flat-icons-orange ultra-flat-icons-green codeblocks indicator-sysmonitor -y
# VLC, Unity Tweak Tool, GIMP, Shutter
echo "$PASSWORD" | sudo -S apt-get install vlc unity-tweak-tool gimp gimp-gap gimp-helpbrowser gimp-help-common shutter -y
# Wine: TrueType core fonts for the web eula, eula license terms
# Vim, SSH, Git, Unzip
echo "$PASSWORD" | sudo -S apt-get install vim openssh-client openssh-server git unzip -y
# Config Git
git config --global user.name "pentonbin"
git config --global user.email "[email protected]"
# Install deb packages
cd $DEB_PATH
# Dpkg install
echo "$PASSWORD" | sudo -S dpkg -i *.deb
# Install dependency
echo "$PASSWORD" | sudo -S apt-get -f install -y
#######################################################################
# copy the script
#######################################################################
chmod a+x $SCRIPT_PATH/*
echo "$PASSWORD" | sudo cp $SCRIPT_PATH/* /usr/bin/
#######################################################################
# unzip and install app
#######################################################################
# Java
cd $TAR_GZ_PATH
# Get package name
jdk_pkg=$(ls -l | grep -i jdk | awk '{ print $9 }')
# File exist
if [ ! -z "$jdk_pkg" ]; then
# Copy and unzip
cp $jdk_pkg $JAVA_PATH
cd $JAVA_PATH
if [ "${jdk_pkg##*.}" = "zip" ]; then
unzip $jdk_pkg
elif [ "${jdk_pkg##*.}" = "gz" ]; then
tar zxvf $jdk_pkg
fi
rm $jdk_pkg
# Get JAVA_HOME path
cd $(ls -l | grep -i jdk | awk '{ print $9 }')
JAVA_HOME="$(pwd)"
JRE_HOME="$JAVA_HOME/jre"
# Write profile
echo "# JAVA" | sudo tee -a /etc/profile
echo "export JAVA_HOME=$JAVA_HOME" | sudo tee -a /etc/profile
echo "export JRE_HOME=$JRE_HOME" | sudo tee -a /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' | sudo tee -a /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib' | sudo tee -a /etc/profile
source /etc/profile
fi
# Android studio
cd $TAR_GZ_PATH
android_pkg=$(ls -l | grep -i studio | awk '{ print $9 }')
if [ ! -z "$android_pkg" ]; then
cp $android_pkg $ANDROID_PATH
cd $ANDROID_PATH
if [ "${android_pkg##*.}" = "zip" ]; then
unzip $android_pkg
elif [ "${android_pkg##*.}" = "gz" ]; then
tar zxvf $android_pkg
fi
rm $android_pkg
fi
# Idea
cd $TAR_GZ_PATH
idea_pkg=$(ls -l | grep -i idea | awk '{ print $9 }')
if [ ! -z "$idea_pkg" ]; then
cp $idea_pkg $IDEA_PATH
cd $IDEA_PATH
if [ "${idea_pkg##*.}" = "zip" ]; then
unzip $idea_pkg
elif [ "${idea_pkg##*.}" = "gz" ]; then
tar zxvf $idea_pkg
fi
rm $idea_pkg
fi
# PyCharm
cd $TAR_GZ_PATH
pycharm_pkg=$(ls -l | grep -i pycharm | awk '{ print $9 }')
if [ ! -z "$pycharm_pkg" ]; then
cp $pycharm_pkg $PYCHARM_PATH
cd $PYCHARM_PATH
if [ "${pycharm_pkg##*.}" = "zip" ]; then
unzip $pycharm_pkg
elif [ "${pycharm_pkg##*.}" = "gz" ]; then
tar zxvf $pycharm_pkg
fi
rm $pycharm_pkg
fi
# Wechat
cd $TAR_GZ_PATH
wechat_pkg=$(ls -l | grep -i wechat | awk '{ print $9 }')
if [ ! -z "$wechat_pkg" ]; then
cp $wechat_pkg $WECHAT_PATH
cd $WECHAT_PATH
if [ "${wechat_pkg##*.}" = "zip" ]; then
unzip $wechat_pkg
elif [ "${wechat_pkg##*.}" = "gz" ]; then
tar zxvf $wechat_pkg
fi
rm $wechat_pkg
fi
# iNode
cd $TAR_GZ_PATH
inode_pkg=$(ls -l | grep -i iNode | awk '{ print $9 }')
if [ ! -z "$inode_pkg" ]; then
cp $inode_pkg $INODE_PATH
cd $INODE_PATH
if [ "${inode_pkg##*.}" = "zip" ]; then
unzip $inode_pkg
elif [ "${inode_pkg##*.}" = "gz" ]; then
tar zxvf $inode_pkg
fi
rm $inode_pkg
fi
#######################################################################
# Others
#######################################################################
cd $HOSTS_PATH
if [ -r "hosts" ]; then
echo "$PASSWORD" | sudo -S cp hosts /etc/
fi
#######################################################################
# Final update & clean
#######################################################################
echo "$PASSWORD" | sudo -S apt-get update
echo "$PASSWORD" | sudo -S apt-get upgrade -y
echo "$PASSWORD" | sudo -S apt-get clean
echo "$PASSWORD" | sudo -S apt-get autoremove -y
echo "Finished! Had better reboot the ubuntu!"