Skip to content

Commit

Permalink
fix: bad exit 1 syntax on success
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Feb 15, 2024
1 parent 0b88173 commit 19c3c52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/srvinfra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 19c3c52

Please sign in to comment.