-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrotli.sh
More file actions
executable file
·66 lines (48 loc) · 1.22 KB
/
brotli.sh
File metadata and controls
executable file
·66 lines (48 loc) · 1.22 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
66
#!/usr/bin/env bash
set -ex
VER=$(/usr/sbin/nginx -v 2>&1 || :)
NGINX_VER="${VER##*\/}"
if [ -z "$NGINX_VER" ]; then
echo nginx ver not found
exit
fi
DIR="$(dirname "$(readlink -f "$0")")" && cd "$DIR" || exit 1
CURRENT_VER=''
VER_FILE="${DIR}/ver.txt"
if [ -f "$VER_FILE" ]; then
CURRENT_VER=$(cat "$VER_FILE")
fi
if [ "$CURRENT_VER" == "$NGINX_VER" ]; then
echo
echo "newest version '$NGINX_VER', no need update"
echo
exit
fi
TARGET="/etc/nginx/modules"
BR_DIR="ngx_brotli"
SRC_DIR="/usr/local/src"
sudo apt install -y libpcre3-dev
cd "$SRC_DIR"
NGINX_NAME="nginx-${NGINX_VER}"
NGINX_TGZ="${NGINX_NAME}.tar.gz"
if [ ! -d "$NGINX_NAME" ]; then
curl "https://nginx.org/download/${NGINX_TGZ}" -o "$NGINX_TGZ"
tar xzf "$NGINX_TGZ"
fi
if [ ! -d "$BR_DIR" ]; then
git clone "https://github.com/google/ngx_brotli.git"
fi
(
cd "$BR_DIR"
git pull
git submodule update --init --recursive
)
cd "$NGINX_NAME"
make clean >/dev/null 2>&1 || :
./configure --with-compat --add-dynamic-module="${SRC_DIR}/${BR_DIR}"
make modules
sudo service nginx stop || :
sudo cp objs/ngx_http_brotli_filter_module.so "$TARGET"
sudo cp objs/ngx_http_brotli_static_module.so "$TARGET"
echo "$NGINX_VER" > "$VER_FILE"
sudo service nginx start || :