-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathcentos7-installScript
381 lines (314 loc) · 10.1 KB
/
centos7-installScript
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
#!/bin/sh
#------------------------------------------
# Centos7 asp.net InstallScript
# copyright https://github.com/cjy37
# email: [email protected]
#------------------------------------------
function showMenu()
{
clear
echo
echo "--------------------------------------------------------------"
echo "| Centos7 Install Helper |"
echo "| 版权所有 https://github.com/cjy37 |"
echo "--------------------------------------------------------------"
echo "| a. 安装全部组件 |"
echo "| b. 安装 Web 服务 (linux mono mysql jexus)[c,d] |"
echo "| c. 安装 Mono & Jexus (Asp.Net Web Server) |"
echo "| d. 安装 Mysql (MariaDB-10) |"
echo "| e. 安装 Haproxy |"
echo "| f. 安装 Redis |"
echo "| g. 安装 Node.js |"
echo "| h. 安装 MongoDB |"
echo "| i. 安装 Nginx |"
echo "| j. 安装 Memcached |"
echo "| x. 退出 |"
echo "--------------------------------------------------------------"
echo
return 0
}
function selectCmd()
{
alias cp='cp'
showMenu
echo "请选择要安装的字母序号 [a-x]:"
read -n 1 M
echo
if [ "$M" = "x" ]; then
exit 1
elif [ "$M" = "a" ]; then
echo "安装 全部组件..."
echo "------------------------------------"
setupMono && setupJws && setupMysql && setupHaproxy && setupRedis && setupNodejs && setupMemcached && setupNginx && setupMongodb && setupCutyCapt && setupGtkSharp
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "b" ]; then
echo "安装 Web 服务(linux mono mysql jexus) (lmmj) [c,d]"
echo "------------------------------------"
setupMono && setupJws && setupMysql
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "c" ]; then
setupMono && setupJws
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "d" ]; then
setupMysql
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "e" ]; then
setupHaproxy
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "f" ]; then
setupRedis
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "g" ]; then
setupNodejs
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "h" ]; then
setupMongodb
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "i" ]; then
setupNginx
read -n 1 -p "按 <Enter> 继续..."
elif [ "$M" = "j" ]; then
setupMemcached
read -n 1 -p "按 <Enter> 继续..."
else
echo "选择错误!"
read -n 1 -p "按 <Enter> 继续..."
fi
selectCmd
return 0
}
function setupNodejs()
{
if [ ! -d /wwwroot ]; then
sudo mkdir -pv /wwwroot
sudo chmod 777 wwwroot/
fi
if [ ! -d /wwwroot/node_mqtt ]; then
mkdir -pv /wwwroot/node_mqtt
fi
echo "install Node.js"
echo "------------------------------------"
yum -y install nodejs npm
echo "Install nodejs completed. info:"
node -v
echo "------------------------------------"
sudo echo "sudo npm install mqtt|websocket|socket.io|log4js|pm2"
cd /wwwroot/node_mqtt
sudo npm install mqtt -g
sudo npm install websocket -g
sudo npm install websocket-server -g
sudo npm install [email protected] -g
sudo npm install log4js -g
sudo npm install pm2 -g --unsafe-perm
return $?
}
function setupMongodb()
{
echo "install Mongodb"
echo "------------------------------------"
yum -y install mongodb mongodb-server
echo "Install mongodb completed. info:"
mongod --version
echo "------------------------------------"
return $?
}
function setupOs7Epel()
{
echo "Install Centos7_64bit EPEL repository"
rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
yum -y install yum-priorities
return $?
}
function setupOs6Epel()
{
echo "Install Centos6_64bit EPEL repository"
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
yum -y install yum-priorities
return $?
}
function setupOs5Epel()
{
echo "Install Centos5_64bit EPEL repository"
rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5
yum -y install yum-priorities
return $?
}
function setupLibs()
{
vers=`cat /etc/redhat-release | awk -F'release' '{print $2}' | awk -F'.' '{print $1}' | awk -F' ' '{print $1}'`
if [ "$vers" = "7" ]; then
setupOs7Epel
elif [ "$vers" = "6" ]; then
setupOs6Epel
elif [ "$vers" = "5" ]; then
setupOs5Epel
fi
yum -y update
yum -y groupinstall "Development Tools"
echo "安装公共组件..."
echo "------------------------------------"
if [ ! -d /usr/local/webserver ]; then
mkdir -pv /usr/local/webserver
fi
if [ ! -d /wwwroot/htdocs/www ]; then
mkdir -pv /wwwroot/htdocs/www
fi
if [ ! -d /tmp/downloads ]; then
mkdir -pv /tmp/downloads
fi
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers patch make jpackage-utils build-essential bzip bison pkgconfig glib-devel httpd-devel libX11-devel fontconfig pango-devel ruby ruby-rdoc gtkhtml38-devel wget gettext gcc-g77 automake fiex* libmcrypt* libtool-ltdl-devel* pcre* cmake mhash* libevent libevent-devel gif* libtiff* libjpeg* libx11* libiconv mcrypt
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 setupMemcached()
{
echo "install Memcached"
echo "------------------------------------"
yum -y install memcached*
echo "Install Memcached completed. info:"
return $?
}
function setupMono()
{
echo "安装 mono"
echo "------------------------------------"
#yum -y install mono-*
cd /tmp
wget http://download.mono-project.com/repo/xamarin.gpg
rpm --import xamarin.gpg
#yum-config-manager --add-repo http://download.mono-project.com/repo/centos/
yum-config-manager --add-repo http://download.mono-project.com/repo/centos-beta/
yum -y install mono-complete
yum -y install ca-certificates-mono
echo "安装 mono 完成. 信息:"
mono -V
echo "------------------------------------"
return $?
}
function setupMysql()
{
echo "安装 mysql"
echo "------------------------------------"
echo '# MariaDB 10.0 CentOS repository list - created 2014-10-18 16:58 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1' > /etc/yum.repos.d/MariaDB.repo
yum -y install MariaDB-server MariaDB-client MariaDB-devel
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
chkconfig --level 2345 mysql on
service mysql start
mysql -V
echo "------------------------------------"
echo "Mysql: Please Ender user(root) password"
read -e PWD
mysqladmin -uroot password "$PWD"
return $?
}
function setupMosquitto()
{
echo "install Mosquitto"
echo "------------------------------------"
echo '[home_oojah_mqtt]
name=mqtt (CentOS_CentOS-7)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/repodata/repomd.xml.key
enabled=1
' > /etc/yum.repos.d/Mosquitto.repo
yum -y install mosquitto mosquitto-clients libmosquitto1 libmosquitto-devel libmosquittopp1 libmosquittopp-devel python-mosquitto
mosquitto -h
echo "------------------------------------"
return $?
}
function setupNginx()
{
echo "install nginx"
echo "------------------------------------"
echo '[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1' > /etc/yum.repos.d/nginx.repo
yum -y install nginx
chkconfig --level 2345 nginx on
service nginx start
nginx -v
echo "------------------------------------"
return $?
}
function setupHaproxy()
{
echo "install haproxy"
echo "------------------------------------"
yum -y install haproxy
echo "Install haproxy completed. info:"
haproxy -v
echo "------------------------------------"
return $?
}
function setupRedis()
{
echo "install redis"
echo "------------------------------------"
yum -y install redis
echo "Install Redis completed. info:"
redis-server -v
echo "------------------------------------"
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
if [ ! -d /usr/jexus ]; then
mkdir -pv /usr/jexus
echo "/usr/jexus/jws start" >> /etc/rc.local
fi
echo "安装 jexus"
echo "------------------------------------"
cd /tmp/downloads
wget -c http://www.linuxdot.net/down/jexus-5.8.1-x64.tar.gz
if [ -f jexus-5.8.1-x64.tar.gz ]; then
tar -xf jexus-5.8.1-x64.tar.gz
cd jexus-5.8.1-x64
./install
chmod +x /usr/jexus/*
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
cp -r -f index.aspx /wwwroot/htdocs/www/index.aspx
echo "站点根目录: /wwwroot/htdocs/www/"
echo "如果你要更新它. 请修改 Jexus 配置文件:(/usr/jexus/siteconf/*)"
fi
/usr/jexus/jws start
/usr/jexus/jws -V
echo "------------------------------------"
echo "Jexus 安装目录: /usr/jexus/"
echo "Jexus 配置文件:(/usr/jexus/jws.conf and /usr/jexus/siteconf/*)"
return $?
}
cd /tmp
read -n 1 -p "按任意键安装公共组件. 按 [Ctrl + C] 取消安装."
setupLibs
selectCmd