diff options
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 |
