-
Notifications
You must be signed in to change notification settings - Fork 275
/
release.sh
executable file
·276 lines (243 loc) · 5.86 KB
/
release.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/usr/bin/env bash
MAKE=1
CLEAN=0
INSTALL=0
REBUILD=0
INSTALL_PATH="/usr/local/"
SERVICENAME="pingos"
OPWD=`pwd`
UNINSTALL=0
while getopts 'mcirup:s:' OPT; do
case $OPT in
m)
MAKE=1
;;
c)
CLEAN=1
;;
i)
INSTALL=1
;;
u)
UNINSTALL=1
;;
r)
REBUILD=1
;;
p)
INSTALL_PATH=$OPTARG
;;
s)
SERVICENAME=$OPTARG
;;
?)
echo "Usage: `basename $0` [-m make] [-i install] [-c clean] [-p install path] [-s service name] [-r rebuild] [-u uninstall]"
exit 1
esac
done
SERVER_ROOT=$INSTALL_PATH$SERVICENAME
WWW_ROOT=$SERVER_ROOT"/html"
if [ $UNINSTALL == 1 ]
then
while :
do
echo "remove $SERVER_ROOT [Y/N] "
read YN
case $YN in
y)
break
;;
Y)
break
;;
yes)
break
;;
YES)
break
;;
n)
exit 1
;;
N)
exit 1
;;
no)
exit 1
;;
NO)
exit 1
;;
?)
echo "invalid input $YN"
esac
done
echo "removing $SERVER_ROOT ..."
if [ -d $SERVER_ROOT ]
then
rm -rf $SERVER_ROOT
fi
exit 1
fi
echo "server root: "$SERVER_ROOT
echo "www root: "$WWW_ROOT
scanOS(){
OS=`uname -s`
if [ ${OS} == "Darwin" ]
then
PM="brew"
elif [ ${OS} == "Linux" ]
then
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
DISTRO='CentOS'
PM='yum'
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
DISTRO='RHEL'
PM='yum'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
DISTRO='Aliyun'
PM='yum'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
DISTRO='Fedora'
PM='yum'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='Debian'
PM='apt-get'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
PM='apt-get'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
DISTRO='Raspbian'
PM='apt-get'
else
DISTRO='unknow'
fi
else
echo ${OS}
fi
echo ${PM}
}
modules=(
"--with-http_ssl_module"
"--add-module=../modules/nginx-rtmp-module"
"--add-module=../modules/nginx-client-module"
"--add-module=../modules/nginx-multiport-module"
"--add-module=../modules/nginx-toolkit-module"
)
options=( "--prefix=$SERVER_ROOT" )
if [ $CLEAN == 1 ]
then
if [ -d nginx ]
then
cd nginx
echo "cleanup ..."
make clean
cd ..
fi
exit 1
fi
if [ $REBUILD == 1 ]
then
if [ -d nginx ]
then
cd nginx
if [ -e Makefile ]
then
make clean
fi
cd ..
fi
fi
CMD=`scanOS`
if [ ! -d "./nginx/objs" ]
then
# depend
if [ "$CMD" == "yum" ]
then
yum install -y git gcc gcc-c++ openssl openssl-devel pcre-devel wget
elif [ "$CMD" == "apt-get" ]
then
apt-get install -y wget
apt-get install -y build-essential
apt-get install -y libtool
apt-get update
apt-get install -y libpcre3 libpcre3-dev
apt-get install -y zlib1g-dev
apt-get install -y openssl
apt-get install -y libssl-dev
elif [ "$CMD" == "brew" ]
then
brew install openssl pcre
options[${#options[*]}]='--with-ld-opt="-L/usr/local/opt/openssl/lib/ -L/usr/local/opt/pcre/lib/"'
options[${#options[*]}]='--with-cc-opt="-I/usr/local/opt/openssl/include/ -I/usr/local/opt/pcre/include/"'
else
echo "$CMD not supported"
exit 1
fi
fi
if [ ! -d "./nginx" ]
then
if [ ! -f "./nginx-1.17.5.tar.gz" ]; then
wget https://nginx.org/download/nginx-1.17.5.tar.gz
fi
tar zxvf nginx-1.17.5.tar.gz
mv nginx-1.17.5 nginx
rm -f nginx-1.17.5.tar.gz
cp resource/conf-template/nginx.conf nginx/conf/nginx.conf
fi
cd nginx
if [ ! -f "Makefile" ]
then
if [ ! -f "configure" ]
then
config="./auto/configure"
else
config="./configure"
fi
for option in ${options[*]}
do
config=$config" "$option
done
for module in ${modules[*]}
do
config=$config" "$module
done
echo $config
bash -c "$config"
fi
if [ -f "Makefile" ]
then
if [ $MAKE == 1 ] || [ $REBUILD == 1 ] || [ $INSTALL == 1 ]
then
make -j4
fi
if [ $INSTALL ]
then
make install
cd $OPWD
if [ ! -f $SERVER_ROOT"/conf/nginx.conf" ]
then
if [ "$CMD" == "brew" ]
then
cp ./resource/conf-template/nginx-macos.conf $SERVER_ROOT"/conf/nginx.conf"
else
cp ./resource/conf-template/nginx.conf $SERVER_ROOT"/conf/nginx.conf"
fi
fi
if [ ! -f $WWW_ROOT"/stat.xsl" ]
then
cp ./resource/stat.xsl $WWW_ROOT"/stat.xsl"
fi
if [ ! -f $WWW_ROOT"/crossdomain.xml" ]
then
cp ./resource/crossdomain.xml $WWW_ROOT"/crossdomain.xml"
fi
if [ ! -d $WWW_ROOT"/h5player" ]
then
cd $WWW_ROOT
#git clone https://github.com/pingostack/h5player.git
cd $OPWD
fi
fi
fi
cd $OPWD