From c0875c44c493fc22b9700a173630d2f1d4a31000 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 10 Mar 2022 12:19:02 +0100 Subject: [PATCH] Checking existence of password files before --- scripts/disabling-ldap-user | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/disabling-ldap-user b/scripts/disabling-ldap-user index 50e1025..18254ef 100755 --- a/scripts/disabling-ldap-user +++ b/scripts/disabling-ldap-user @@ -9,7 +9,7 @@ QUIET='n' SIMULATE='n' YES="n" -VERSION="1.3" +VERSION="1.4" # console colors: RED="" @@ -919,6 +919,25 @@ main() { trap cleanup_tmp_file INT TERM EXIT ABRT + empty_line + info "Checking existence of necessary password files ..." + local all_files_there="y" + for INSTANCE in "${USED_INSTANCES[@]}" ; do + BIND_PW_FILE="${BIND_PW_FILES[${INSTANCE}]}" + debug "Checking for '${CYAN}${BIND_PW_FILE}${NORMAL}'." + if [[ -f "${BIND_PW_FILE}" && -r "${BIND_PW_FILE}" ]] ; then + debug "Password file '${CYAN}${BIND_PW_FILE}${NORMAL}' exists and is readable." + else + error "Password file '${RED}${BIND_PW_FILE}${NORMAL}' does not exists or is not redable." + all_files_there="n" + fi + done + empty_line + + if [[ "${all_files_there}" == "n" ]] ; then + exit 6 + fi + for USER in "${USERS[@]}" ; do for INSTANCE in "${USED_INSTANCES[@]}" ; do LDAP_URL="${LDAP_URLS[${INSTANCE}]}" -- 2.39.5