Change handling od database files.

This commit is contained in:
2017-09-23 01:59:34 +02:00
parent e04e224888
commit ce28ffd467
3 changed files with 92 additions and 3 deletions

View File

@@ -212,7 +212,14 @@ fi
if [[ -n "$DATABASE_NAME" ]] ; then
if [[ -z "$DATABASE_USER" || -z "$DATABASE_PASSWD" ]] ; then
if [[ -f "${working_dir}/databases/$DATABASE_NAME" ]]; then
read_file=""
if [[ -f "${working_dir}/databases/DELETED/$DATABASE_NAME" ]]; then
read_file="${working_dir}/databases/DELETED/$DATABASE_NAME"
elif [[ -f "${working_dir}/databases/$DATABASE_NAME" ]]; then
read_file="${working_dir}/databases/$DATABASE_NAME"
fi
if [[ -n "$read_file" ]]; then
while read -r _db_name _db_user _db_pass ; do
# - if var '_db_name' begins with '#', that means the readed line
@@ -231,11 +238,12 @@ if [[ -n "$DATABASE_NAME" ]] ; then
break
fi
done < "${working_dir}/databases/$DATABASE_NAME"
done < "$read_file"
fi
fi
fi
if $NON_INTERACTIVE_MODE ; then
if [[ -z "$DATABASE_USER" ]]; then
fatal "Database user not given. Maybe missing or wrong file '${working_dir}/databases/$DATABASE_NAME'."
@@ -429,6 +437,36 @@ else
echo_ok
fi
if ! $QUIET_MODE ; then
echo ""
fi
echononl " Create directory '${working_dir}/databases'.."
if [[ -d "${working_dir}/databases" ]]; then
echo_skipped
else
mkdir ${working_dir}/databases > $tmp_log_file 2>&1
if [[ $? -ne 0 ]] ; then
echo_failed
error "$(cat $tmp_log_file)"
else
echo_ok
fi
fi
echononl " Remove file '${working_dir}/databases/DELETED/$DATABASE_NAME'"
if [[ -f "${working_dir}/databases/DELETED/$DATABASE_NAME" ]] ; then
rm "${working_dir}/databases/DELETED/$DATABASE_NAME" > $tmp_log_file 2>&1
if [[ $? -ne 0 ]] ; then
echo_failed
error "$(cat $tmp_log_file)"
else
echo_ok
fi
else
echo_skipped
fi
echononl " Create/Renew file '${working_dir}/databases/$DATABASE_NAME'"
cat <<EOF > "${working_dir}/databases/$DATABASE_NAME" 2> $tmp_log_file 2>&1
# <db-name> <db-user> <dp-pass>