This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/scripts/build-nginx-vts.sh
2018-07-23 16:44:19 -04:00

96 lines
3.4 KiB
Bash
Executable file

#!/bin/bash
if [ -z "${1}" ]; then
echo "Please specify a vts version to install."
exit 1
fi
set -euo pipefail
VTS_VERSION="${1}"
NGINX_VERSION="$(nginx -v 2>&1 | cut -d '/' -f 2)"
MODULES_DIR="/usr/lib/nginx/modules"
BUILD_PATH="/tmp/build"
VTS_PATH="${BUILD_PATH}/nginx-module-vts-${VTS_VERSION}"
mkdir -p "${BUILD_PATH}"
mkdir -p "${VTS_PATH}"
cd "${BUILD_PATH}"
echo "==> Downloading nginx-module-vts..."
curl -fsSL -o "nginx-module-vts-${VTS_VERSION}.tar.gz" \
"https://github.com/vozlt/nginx-module-vts/archive/${VTS_VERSION}.tar.gz"
# The directory in the tarball (infuriatingly) doesn't include the
# leading "v" in the version number, so this normalizes it.
tar xzf "nginx-module-vts-${VTS_VERSION}.tar.gz" -C "${VTS_PATH}" \
--strip-components 1
echo "==> Downloading nginx source..."
apt-get source -y nginx
apt-get install -y libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5
echo "==> Building nginx-module-vts..."
cd "nginx-${NGINX_VERSION}"
CCFLAGS='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC'
LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
(
# The options here need to match the output of `nginx -v`.
./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt="${CCFLAGS}" \
--with-ld-opt="${LDFLAGS}" \
--add-dynamic-module="${VTS_PATH}"
make modules
) 1>/dev/null
echo "==> Installing nginx-module-vts..."
cp -a objs/ngx_http_vhost_traffic_status_module.so \
"${MODULES_DIR}/ngx_http_vhost_traffic_status_module.so"
echo "==> Cleaning up..."
cd / && rm -fr "${BUILD_PATH}"
apt-get purge -y libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5