-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp-make
executable file
·60 lines (45 loc) · 3.63 KB
/
http-make
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
#!/bin/sh -e
cd $(dirname $0)
WORKDIR=$(pwd)
if ! cat /etc/lsb-release 2>/dev/null | grep xenial$ >/dev/null; then
echo "Ubuntu 16.04 LTS is needed for this build environment" && exit 1
fi
! echo "$1" | grep -E "^[A-Za-z_][A-Za-z0-9_]*$" >/dev/null && echo "Context name should be non-empty and only contain letters, '_' and non-leading zeros" && exit 1
[ ! -e ./applications/$1/config ] && echo "Context '$1' doesn't exist!" && exit 1
mkdir -p .build/
cd .build
rm -rf nginx-*
# curl -L http://nginx.org/download/nginx-1.10.0.tar.gz | tar xzvf -
if ! dpkg -l dpkg-dev nginx-core >/dev/null 2>&1; then
sudo apt-get install dpkg-dev nginx-core
sudo apt-get build-dep nginx
fi
apt-get source nginx
apt-get build-dep nginx || true
cd nginx-*
VERSION=$(nginx -v 2>&1 | awk '{ print $(NF-1); }' | cut -d \/ -f 2)
if [ ! -e ../../applications/$1/resources/bin ] || [ "$SKIP" != "y" ]; then
if [ "$DOCKER" = "y" ]; then
sed -i 's/'${VERSION}'/1010001/g' ./src/core/nginx.h
./configure --add-dynamic-module=../../applications/$1 --prefix=/var/lib/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/run/nginx/nginx.pid --lock-path=/run/nginx/nginx.lock --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --user=nginx --group=nginx --with-ipv6 --with-file-aio --with-pcre-jit --with-http_dav_module --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_v2_module --with-http_auth_request_module --with-mail --with-mail_ssl_module
else
./configure --add-dynamic-module=../../applications/$1 --with-cc-opt='-g -O2 -fPIC -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads
fi
mkdir -p ../../applications/$1/resources/bin
fi
make modules
cp objs/ngx_http_$1_module.so ../../applications/$1/resources/bin/ngx_http_$1_module_$(uname -m).so
echo "============================================="
echo "Module Output: ngx_http_$1_module.so"
echo "============================================="
if [ "$DOCKER" = "y" ]; then
cd ${WORKDIR}
PACKAGE=$(git config --get remote.origin.url 2>/dev/null | awk -F '[\/\:]' '{print $(NF-1) "/"}')$1
sudo docker build -t ${PACKAGE} -f Dockerfile.in --build-arg APPNAME=$1 .
echo -e "Done. You can execute the appplication via docker like:\n"
cat <<EOF
docker run -it --rm --net=host -e LISTEN="8080" ${PACKAGE}
docker run -it --rm --net=host -e LISTEN="8443 ssl" ${PACKAGE}
docker run -it --rm --net=host -e LISTEN="8443 ssl" -e ACCOUNT="admin:badmin" ${PACKAGE}
EOF
fi