diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-07-12 07:52:42 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-07-12 07:52:42 +0100 |
| commit | 799dc834e0fe94ed62c0d6bb65e6d15a639ab668 (patch) | |
| tree | bb3b7a89764f768b6b1c4a4918e9eb37a88645b8 /nginx.sh | |
| download | lfldap-1.0.tar.gz lfldap-1.0.tar.bz2 | |
initial commitv1.0
Diffstat (limited to 'nginx.sh')
| -rw-r--r-- | nginx.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/nginx.sh b/nginx.sh new file mode 100644 index 0000000..cb080e9 --- /dev/null +++ b/nginx.sh @@ -0,0 +1,26 @@ +# This source code is released into the public domain. +# +# The nginx allow_internal.conf file is a list of "allow <prefix>;", +# one per line, followed by "deny all;". + +NGINX_FILE="/usr/local/etc/nginx/allow_internal.conf" +NGINX_TEMP="${NGINX_FILE}.ldaptmp" + +if [ ! -f "$NGINX_FILE" ]; then + exit 0 +fi + +awk <"$NETWORKS_FILE" >"$NGINX_TEMP" '{ print "allow " $1 ";" }' +printf >>"$NGINX_TEMP" 'deny all;\n' + +if cmp -s "$NGINX_TEMP" "$NGINX_FILE"; then + rm "$NGINX_TEMP" + exit 0 +fi + +printf '%s updated:\n\n' "$NGINX_FILE" +diff "$NGINX_FILE" "$NGINX_TEMP" +printf '\n' + +mv "$NGINX_TEMP" "$NGINX_FILE" +/usr/local/sbin/nginx -s reload |
