From 19c3c522f021aedfc571dae9d9d8da856b5041b4 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:26:12 -0700 Subject: [PATCH] fix: bad exit 1 syntax on success --- CHANGELOG.md | 4 ++++ src/srvinfra.sh | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81ab175..89a90d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v1.2.1 (2024-02-15) + +- Fix a bug introduced in the last version that would exit with code 1 even with success due to bad syntax + ## v1.2.0 (2024-02-08) - Adds file checks on output database exports to ensure they are valid diff --git a/src/srvinfra.sh b/src/srvinfra.sh index 1a5210e..598e254 100755 --- a/src/srvinfra.sh +++ b/src/srvinfra.sh @@ -33,7 +33,10 @@ export_database() { local sql_filename sql_filename=${4:-"database.sql"} - docker exec -i "$1" "$SRVINFRA_DATABASE_BACKUP_EXECUTABLE" -uroot -p"$2" "$3" >"$sql_filename" || echo "Could not export database!" && exit 1 + docker exec -i "$1" "$SRVINFRA_DATABASE_BACKUP_EXECUTABLE" -uroot -p"$2" "$3" >"$sql_filename" || { + echo "Could not export database!" + exit 1 + } # Check if we generate a proper export if [[ $(file "$sql_filename") != *ASCII\ text || ! -s "$sql_filename" ]]; then @@ -51,7 +54,10 @@ export_database_secure() { local sql_filename sql_filename=${4:-"database.enc.gz"} - docker exec -i "$1" "$SRVINFRA_DATABASE_BACKUP_EXECUTABLE" -uroot -p"$2" "$3" | gzip -c | openssl enc -aes-256-cbc -md sha512 -pbkdf2 -k "$2" >"$sql_filename" || echo "Could not export database!" && exit 1 + docker exec -i "$1" "$SRVINFRA_DATABASE_BACKUP_EXECUTABLE" -uroot -p"$2" "$3" | gzip -c | openssl enc -aes-256-cbc -md sha512 -pbkdf2 -k "$2" >"$sql_filename" || { + echo "Could not export database!" + exit 1 + } # Check if we generate a proper export if [[ $(file "$sql_filename") != *"openssl enc'd data with salted password" || ! -s "$sql_filename" ]]; then