uprgade-keycloak.sh: Changes when importing existing configuration files.

This commit is contained in:
2026-04-03 01:17:13 +02:00
parent 8a1230eadf
commit 27c82a9634

View File

@@ -643,41 +643,67 @@ else
echo_skipped echo_skipped
fi fi
echononl "Copy 'conf/ directory from the previous installation to the new installation."
#cp -a "${CUR_INSTALL_DIR}.${backup_date}/conf" "${KEYCLOAK_INSTALL_DIR}/" > "$log_file" 2>&1 echononl "Copy configuration files from the previous installation to the new installation."
# shopt -s extglob _failed=false
# cp -r ${CUR_INSTALL_DIR}.${backup_date}/conf/!('cache-ispn.xml'|'README.md') \ : > "$log_file"
# ${KEYCLOAK_INSTALL_DIR}/conf/ > "$log_file" 2>&1
# shopt -u extglob
find "${CUR_INSTALL_DIR}.${backup_date}/conf" -type f \
! -name 'cache-ispn.xml' \
! -name 'README.md' \
! -name 'keycloak.conf.ORIG' \
-exec cp --parents {} "${KEYCLOAK_INSTALL_DIR}/conf" \; > "$log_file" 2>&1
if [[ $? -ne 0 ]]; then SRC_DIR="${CUR_INSTALL_DIR}.${backup_date}/conf"
echo_failed DST_DIR="${KEYCLOAK_INSTALL_DIR}/conf"
error "$(cat "$log_file")"
if $terminal ; then for ext in conf json; do
echononl "\033[1mcontinue anyway\033[m [yes/no]: " # Prüfen ob überhaupt Dateien mit dieser Endung existieren
read OK shopt -s nullglob
while [[ "${OK,,}" != "yes" ]] && [[ "${OK,,}" != "no" ]] ; do files=("${SRC_DIR}"/*.${ext})
echononl "Wrong entry! - repeat [yes/nno]: " shopt -u nullglob
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
if [[ ${#files[@]} -eq 0 ]]; then
# no files *.${ext} found in ${SRC_DIR}
continue
fi fi
for src_file in "${files[@]}"; do
filename=$(basename "${src_file}")
dst_file="${DST_DIR}/${filename}"
# Existierende Zieldatei sichern
if [[ -f "${dst_file}" ]]; then
orig_file="${dst_file}.ORIG"
# Backup '${dst_file}'
# '${dst_file}' -> '${orig_file}'
cp -p "${dst_file}" "${orig_file}" || {
echo "Unable to save '$(basename "${dst_file}")'. The file was not copied to the installation directory." >> "$log_file"
_failed=true
# '${dst_file}' nicht sichern. Überspringe.
continue
}
fi
# Datei ins Zielverzeichnis kopieren
# '${src_file}' -> '${dst_file}'"
cp -p "${src_file}" "${dst_file}" || {
echo " Copying existing '$(basename "${src_file}")' into to installation directory failed!" >> "$log_file"
_failed=true
}
done
done
if ${_failed} ; then
echo_failed
error "$(cat "$log_file")"
else else
echo_ok echo_ok
fi fi
echononl "Copy 'providers/ directory from the previous installation to the new installation." echononl "Copy 'providers/ directory from the previous installation to the new installation."
cp -a "${CUR_INSTALL_DIR}.${backup_date}/providers" "${KEYCLOAK_INSTALL_DIR}/" > "$log_file" 2>&1 cp -a "${CUR_INSTALL_DIR}.${backup_date}/providers" "${KEYCLOAK_INSTALL_DIR}/" > "$log_file" 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then