Only set ldap allowlist if file exists and is not empty

This commit is contained in:
Johannes Zellner
2021-12-15 18:45:51 +01:00
parent d6fbe2a1bb
commit d69758e559
3 changed files with 22 additions and 18 deletions

View File

@@ -14,15 +14,4 @@ fi
[[ "${BOX_ENV}" == "test" ]] && exit
ipset flush cloudron_ldap_allowlist
ldap_allowlist_json="/home/yellowtent/platformdata/firewall/ldap_allowlist.txt"
if [[ -f "${ldap_allowlist_json}" ]]; then
# without the -n block, any last line without a new line won't be read it!
while read -r line || [[ -n "$line" ]]; do
[[ -z "${line}" ]] && continue # ignore empty lines
[[ "$line" =~ ^#.*$ ]] && continue # ignore lines starting with #
ipset add -! cloudron_ldap_allowlist "${line}" # the -! ignore duplicates
done < "${ldap_allowlist_json}"
fi
systemctl restart cloudron-firewall