Last active
April 4, 2021 08:46
-
-
Save mohd-akram/0e35031179bac99a0ef564ce59a628cf to your computer and use it in GitHub Desktop.
A script to build a dynamic Nginx module with the correct configure options.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # A script to build a dynamic Nginx module with the correct configure options. | |
| set -eu | |
| set -o pipefail 2>/dev/null || : | |
| dir="$1" | |
| if [ ! "$dir" ]; then | |
| echo "usage: $0 module_dir" >&2 | |
| exit 1 | |
| fi | |
| getconfopts() { | |
| nginx -V 2>&1 | | |
| sed -nE "s/^configure arguments: //; s/ (--[^' ]+('[^']*')?)/\n\1/pg;" | |
| } | |
| dist=`nginx -v 2>&1 | cut -d' ' -f3 | tr / -` | |
| opts=`getconfopts | grep -- --with-compat || getconfopts` | |
| name=`sed -n 's/^ngx_addon_name=//p' "$dir/config"` | |
| keep= | |
| if [ -d "$dist" ]; then | |
| keep=1 | |
| else | |
| curl "https://nginx.org/download/$dist.tar.gz" | tar -xz | |
| fi | |
| cd "$dir" | |
| dir=`pwd` | |
| cd - | |
| cd "$dist" | |
| echo "$opts" | xargs ./configure --add-dynamic-module="$dir" | |
| make modules | |
| cd - | |
| cp "$dist/objs/$name.so" . | |
| if [ ! "$keep" ]; then | |
| rm -rf "$dist" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment