forked from cjy37/linux-install-script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathubuntu-installScript
More file actions
394 lines (329 loc) · 10.6 KB
/
ubuntu-installScript
File metadata and controls
394 lines (329 loc) · 10.6 KB
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
#!/bin/bash
#------------------------------------------
# Ubuntu12.04 asp.net InstallScript
# copyright https://github.com/cjy37
# email: rocky.cn@foxmail.com
#------------------------------------------
function showMenu()
{
clear
echo
echo "--------------------------------------------------------------"
echo "| Ubuntu12.04 Install Helper |"
echo "| copyright https://github.com/cjy37 |"
echo "--------------------------------------------------------------"
echo "| a. Install ALL |"
echo "| b. Install Web Server (linux mono mysql jexus)[c,d] |"
echo "| c. Install Mono & Jexus (Asp.Net Web Server) |"
echo "| d. Install Mysql (MariaDB-10) |"
echo "| e. Install Haproxy |"
echo "| f. Install Redis |"
echo "| g. Install Node.js |"
echo "| h. Install MongoDB |"
echo "| i. Install Nginx |"
echo "| j. Install MQTT Server |"
echo "| k. *Update Mono & Jexus |"
echo "| l. *Update Jexus (Mono Web Server) |"
echo "| x. Exit |"
echo "--------------------------------------------------------------"
echo
return 0
}
function selectCmd()
{
alias cp='cp'
showMenu
echo "Please select a serial number for installation [a-x]:"
read -n 1 M
echo
if [ "$M" = "x" ]; then
exit 1
elif [ "$M" = "a" ]; then
echo "Installing ALL..."
echo "------------------------------------"
setupNewMono && setupJws && setupMysql && setupHaproxy && setupRedis && setupNodeJS && setupMQTTServer && setupMongoDB && setupNginx
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "b" ]; then
echo "Installing Web Server(linux mono mysql jexus) (lmmj) [c,d]"
echo "------------------------------------"
setupNewMono && setupJws && setupMysql
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "c" ]; then
setupNewMono && setupJws
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "d" ]; then
setupMysql
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "e" ]; then
setupHaproxy
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "f" ]; then
setupRedis
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "g" ]; then
setupNodeJS
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "j" ]; then
setupMQTTServer
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "h" ]; then
setupMongoDB
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "i" ]; then
setupNginx
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "k" ]; then
updateMono && updateJws
read -n 1 -p "Press <Enter> to continue..."
elif [ "$M" = "l" ]; then
updateJws
read -n 1 -p "Press <Enter> to continue..."
else
echo "Select Error!"
read -n 1 -p "Press <Enter> to continue..."
fi
selectCmd
return 0
}
function setupLibs()
{
sudo apt-get update -y
sudo apt-get upgrade -y
echo "Install the public Libs"
echo "------------------------------------"
if [ ! -d /wwwroot/htdocs/www ]; then
sudo mkdir /wwwroot
sudo chmod 777 wwwroot/
mkdir -pv /wwwroot/htdocs/www
fi
if [ ! -d /tmp/downloads ]; then
mkdir -pv /tmp/downloads
fi
cd /tmp
sudo apt-get install -y vim chkconfig
sudo apt-get install -y build-essential
sudo apt-get install -y automake autoconf
sudo apt-get install -y bison gettext libtool libglib2.0-dev libfreetype6-dev libfontconfig-dev
sudo apt-get install -y libgif-dev libtiff4-dev libpng12-dev libexif-dev libx11-dev libxft-dev libjpeg-dev
cd /tmp/downloads
wget -c https://github.com/cjy37/linux-asp.net-installScript/raw/master/conf.zip
if [ -f conf.zip ]; then
unzip -o conf.zip
fi
return $?
}
function updateMono()
{
echo "Update mono"
echo "------------------------------------"
cd /tmp
wget http://download.mono-project.com/repo/xamarin.gpg
apt-key add xamarin.gpg
echo "deb http://download.mono-project.com/repo/debian wheezy main" > /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install -y mono-complete
echo "Install mono completed. info:"
mono -V
echo "------------------------------------"
return $?
}
function setupNewMono()
{
if [ ! -d /wwwroot/htdocs/www ]; then
mkdir -pv /wwwroot/htdocs/www
fi
if [ ! -d /tmp/downloads ]; then
mkdir -pv /tmp/downloads
fi
echo "Install mono"
echo "------------------------------------"
sudo apt-get -f remove -y libmono* mono-jay
sudo apt-get autoremove -y
sudo rm -rf /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install -y mono-complete
cd /tmp
wget http://download.mono-project.com/repo/xamarin.gpg
sudo apt-key add xamarin.gpg
echo "deb http://download.mono-project.com/repo/debian wheezy main" > /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install -y mono-complete
echo "Install mono completed. info:"
mono -V
echo "------------------------------------"
return $?
}
function setupMysql()
{
if [ ! -d /tmp/downloads ]; then
mkdir -pv /tmp/downloads
fi
echo "install mysql"
echo "------------------------------------"
sudo apt-get install -y python-software-properties
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu precise main'
sudo apt-get update -y
sudo apt-get install -y mariadb-server mariadb-client libmariadbd*-dev
sudo cp /usr/share/mysql/my-innodb-heavy-4G.cnf /etc/my.cnf
#sudo sed -i 's/# generic configuration options/user = mysql/g' /etc/my.cnf
sudo sed -i '/\[mysqld\]/a user = mysql' /etc/my.cnf
sudo service mysql start
mysql -V
echo "------------------------------------"
return $?
}
function setupHaproxy()
{
echo "install haproxy"
echo "------------------------------------"
sudo apt-get install -y haproxy
sudo echo "ENABLED=1" > /etc/default/haproxy
sudo service haproxy start
haproxy -v
echo "------------------------------------"
return $?
}
function setupRedis()
{
echo "install Redis"
echo "------------------------------------"
sudo apt-get install -y redis-server
sudo service redis-server start
redis-server -v
echo "------------------------------------"
return $?
}
function setupMongoDB()
{
echo "install MongoDB"
echo "------------------------------------"
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update -y
sudo apt-get install -y mongodb-10gen
sudo apt-get install -y mongodb-10gen=2.4.6
echo "mongodb-10gen hold" | sudo dpkg --set-selections
sudo service mongodb start
mongod --version
echo "------------------------------------"
return $?
}
function setupMQTTServer()
{
echo "install mosquitto(MQTT Server)"
echo "------------------------------------"
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update -y
sudo apt-get install -y python-software-properties
sudo apt-get install -y mosquitto
sudo cp /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
echo "Mosquitto config file: /etc/mosquitto/mosquitto.conf"
sudo service mosquitto start
mosquitto -h
echo "------------------------------------"
return $?
}
function setupNodeJS()
{
echo "install Node.js"
echo "------------------------------------"
if [ ! -d /wwwroot ]; then
sudo mkdir -pv /wwwroot
fi
if [ ! -d /wwwroot/node_mqtt ]; then
mkdir -pv /wwwroot/node_mqtt
fi
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update -y
sudo apt-get install -y nodejs
node -v
echo "------------------------------------"
cd /wwwroot/node_mqtt
sudo echo "sudo npm install mqtt|websocket|socket.io|log4js|pm2"
sudo npm install mqtt -g
sudo npm install websocket -g
sudo npm install websocket-server -g
#sudo npm install socket.io -g
sudo npm install socket.io@0.9 -g
sudo npm install log4js -g
sudo npm install pm2 -g --unsafe-perm
return $?
}
function setupNginx()
{
echo "install Nginx"
echo "------------------------------------"
sudo apt-add-repository ppa:nginx/development
sudo apt-get update
sudo apt-get install nginx
echo "Nginx config file: /etc/nginx/nginx.conf"
nginx -v
echo "------------------------------------"
return $?
}
function updateJws()
{
if [ ! -d /wwwroot/htdocs/www ]; then
mkdir -pv /wwwroot/htdocs/www
fi
if [ ! -d /tmp/downloads ]; then
mkdir -pv /tmp/downloads
fi
echo "upgrade jexus"
echo "------------------------------------"
cd /tmp/downloads
wget -c http://www.linuxdot.net/down/jexus-5.6.3.tar.gz
if [ -f jexus-5.6.3.tar.gz ]; then
tar -xf jexus-5.6.3.tar.gz
cd jexus-5.6.3
sudo /usr/jexus/jws stop
sudo ./upgrade
sudo /usr/jexus/jws start
sudo /usr/jexus/jws -V
echo "------------------------------------"
echo "Jexus upgrade to path: /usr/jexus/"
echo "Jexus config file (/usr/jexus/jws.conf and /usr/jexus/siteconf/*)"
fi
return $?
}
function setupJws()
{
if [ ! -d /wwwroot/htdocs/www ]; then
mkdir -pv /wwwroot/htdocs/www
fi
if [ ! -d /tmp/downloads ]; then
mkdir -pv /tmp/downloads
fi
echo "install jexus"
echo "------------------------------------"
cd /tmp/downloads
wget -c http://www.linuxdot.net/down/jexus-5.6.3.tar.gz
if [ -f jexus-5.6.3.tar.gz ]; then
tar -xf jexus-5.6.3.tar.gz
cd jexus-5.6.3
sudo ./install
sudo chmod +x /usr/jexus/*
sudo sed -i 's/root=\/ \/var\/www\/default/root=\/ \/wwwroot\/htdocs\/www/g' /usr/jexus/siteconf/default
fi
cd /tmp/downloads
wget -c https://github.com/cjy37/linux-asp.net-installScript/blob/master/aspx-info.tar.gz?raw=true
if [ -f aspx-info.tar.gz ]; then
tar xvf aspx-info.tar.gz
cd aspx-info
sudo cp -r -f index.aspx /wwwroot/htdocs/www/index.aspx
echo "Web Root Path: /wwwroot/htdocs/www/"
echo "If you need change it. Please vim the Jexus config file(/usr/jexus/siteconf/*)"
fi
sudo /usr/jexus/jws start
sudo /usr/jexus/jws -V
echo "------------------------------------"
echo "Jexus install to path: /usr/jexus/"
echo "Please vim the Jexus config file (/usr/jexus/jws.conf and /usr/jexus/siteconf/*)"
return $?
}
cd /tmp
read -n 1 -p "Press [Any Key] to setup public libs. [Ctrl + C] to Cancel."
setupLibs
selectCmd