summaryrefslogtreecommitdiffstats
path: root/nginx.sh
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-07-12 07:52:42 +0100
committerLexi Winter <lexi@le-fay.org>2025-07-12 07:52:42 +0100
commit799dc834e0fe94ed62c0d6bb65e6d15a639ab668 (patch)
treebb3b7a89764f768b6b1c4a4918e9eb37a88645b8 /nginx.sh
downloadlfldap-799dc834e0fe94ed62c0d6bb65e6d15a639ab668.tar.gz
lfldap-799dc834e0fe94ed62c0d6bb65e6d15a639ab668.tar.bz2
initial commitv1.0
Diffstat (limited to 'nginx.sh')
-rw-r--r--nginx.sh26
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