-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
67 lines (52 loc) · 2.09 KB
/
install.sh
File metadata and controls
67 lines (52 loc) · 2.09 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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
set -e
#检测是否是root用户
if [ $(id -u) != "0" ]; then
echo "错误:必须使用Root用户才能执行此脚本."
exit 1
fi
read -p "请输入jxwaf_api_key:" JXWAF_API_KEY
if [[ ${JXWAF_API_KEY} = "" ]]; then
exit
elif [[ ${JXWAF_API_KEY} != "" ]]; then
read -p "请输入jxwaf_api_password:" JXWAF_API_PASSWD
if [[ ${JXWAF_API_PASSWD} = "" ]]; then
exit
fi
fi
yum install -y epel-release pcre-devel openssl-devel cmake make curl lua-devel gcc-c++ automake
wget -c https://openresty.org/download/openresty-1.13.6.2.tar.gz
tar zxvf openresty-1.13.6.2.tar.gz
tar zxvf libmaxminddb-1.3.2.tar.gz
tar zxvf aliyun-log-c-sdk-lite.tar.gz
wget -c https://curl.haxx.se/download/curl-7.64.1.tar.gz
tar zxvf curl-7.64.1.tar.gz
cd curl-7.64.1
make
make install
cd ../openresty-1.13.6.2
./configure --prefix=/opt/jxwaf --with-http_v2_module && gmake && gmake install
mv /opt/jxwaf/nginx/conf/nginx.conf /opt/jxwaf/nginx/conf/nginx.conf.bak
cp ../conf/nginx.conf /opt/jxwaf/nginx/conf/
cp ../conf/full_chain.pem /opt/jxwaf/nginx/conf/
cp ../conf/private.key /opt/jxwaf/nginx/conf/
mkdir -p /opt/jxwaf/nginx/conf/jxwaf
cp ../conf/jxwaf_config.json /opt/jxwaf/nginx/conf/jxwaf/
cp ../conf/GeoLite2-Country.mmdb /opt/jxwaf/nginx/conf/jxwaf/
cp -r ../lib/resty/jxwaf /opt/jxwaf/lualib/resty/
cd ../libmaxminddb-1.3.2
./configure
make
cp src/.libs/libmaxminddb.so.0.0.7 /opt/jxwaf/lualib/libmaxminddb.so
cd ../aliyun-log-c-sdk-lite
cmake .
make
cp build/lib/liblog_c_sdk.so.2.0.0 /opt/jxwaf/lualib/liblog_c_sdk.so
ServerIP=`ip addr | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'|grep -v 127.0.0.1|grep -v :|head -1`
HostName=`hostname`
sed -i 's/"waf_api_key": ""/"waf_api_key": "'$JXWAF_API_KEY'"/' /opt/jxwaf/nginx/conf/jxwaf/jxwaf_config.json
sed -i 's/"waf_api_password": ""/"waf_api_password": "'$JXWAF_API_PASSWD'"/' /opt/jxwaf/nginx/conf/jxwaf/jxwaf_config.json
sed -i "s/server_info_detail/$ServerIP|$HostName/g" /opt/jxwaf/nginx/conf/jxwaf/jxwaf_config.json
/opt/jxwaf/nginx/sbin/nginx -t