update aurora, escape sql queries

This commit is contained in:
2025-09-24 20:13:55 +02:00
parent 7ba2f3565e
commit 4a49ef92e2
2 changed files with 6 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# Version: 1.2.1 # Version: 1.2.2
# Exit immediately if a command exits with a non-zero status. # Exit immediately if a command exits with a non-zero status.
set -e set -e
@@ -46,13 +46,13 @@ usage() {
export_schema() { export_schema() {
echo "Starting schema export for '${SCHEMA}'." echo "Starting schema export for '${SCHEMA}'."
mkdir -p "$AURORA_TEMP_DIR" mkdir -p "$AURORA_TEMP_DIR"
run_sql "EXPORT \"${SCHEMA}\".\"*\" AS BINARY INTO '$AURORA_TEMP_DIR' WITH REPLACE;" run_sql "EXPORT \\"${SCHEMA}\\"\\".\\"*\\" AS BINARY INTO '$AURORA_TEMP_DIR' WITH REPLACE;"
echo "Schema export completed." echo "Schema export completed."
} }
import_and_rename() { import_and_rename() {
echo "Starting import and rename to '${AURORA}'." echo "Starting import and rename to '${AURORA}'."
run_sql "IMPORT \"${SCHEMA}\".\"*\" FROM '$AURORA_TEMP_DIR' WITH RENAME SCHEMA \"${SCHEMA}\" TO \"${AURORA}\";" run_sql "IMPORT \\"${SCHEMA}\\"\\".\\"*\\" FROM '$AURORA_TEMP_DIR' WITH RENAME SCHEMA \\"${SCHEMA}\\" TO \\"${AURORA}\";"
echo "Updating company name fields." echo "Updating company name fields."
"$HDBSQL" -U "${BACKOP_USER}" -c ";" -I - <<EOF "$HDBSQL" -U "${BACKOP_USER}" -c ";" -I - <<EOF
UPDATE \"${AURORA}\".CINF SET \"CompnyName\"='AURORA ${COMPNYNAME} ${TIMESTAMP}'; UPDATE \"${AURORA}\".CINF SET \"CompnyName\"='AURORA ${COMPNYNAME} ${TIMESTAMP}';
@@ -64,13 +64,13 @@ EOF
grant_privileges() { grant_privileges() {
echo "Granting privileges on '${AURORA}' to '${AURORA_SCHEMA_USER}'." echo "Granting privileges on '${AURORA}' to '${AURORA_SCHEMA_USER}'."
run_sql "GRANT ALL PRIVILEGES ON SCHEMA \"${AURORA}\" TO \"${AURORA_SCHEMA_USER}\";" run_sql "GRANT ALL PRIVILEGES ON SCHEMA \\"${AURORA}\\" TO \\"${AURORA_SCHEMA_USER}\";"
echo "Privileges granted." echo "Privileges granted."
} }
drop_aurora_schema() { drop_aurora_schema() {
echo "Dropping existing '${AURORA}' schema." echo "Dropping existing '${AURORA}' schema."
run_sql "DROP SCHEMA \"${AURORA}\" CASCADE;" 2>/dev/null || echo "Could not drop schema '${AURORA}'. It might not exist." >&2 run_sql "DROP SCHEMA \\"${AURORA}\\" CASCADE;" 2>/dev/null || echo "Could not drop schema '${AURORA}'. It might not exist." >&2
echo "Old schema dropped." echo "Old schema dropped."
} }

View File

@@ -7,7 +7,7 @@
declare -A SCRIPT_PACKAGES declare -A SCRIPT_PACKAGES
# The version should match the "# Version: x.x.x" line in the main script file. # The version should match the "# Version: x.x.x" line in the main script file.
SCRIPT_PACKAGES["Aurora Suite"]="1.2.1|https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.conf" SCRIPT_PACKAGES["Aurora Suite"]="1.2.2|https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.conf"
SCRIPT_PACKAGES["Backup Suite"]="1.0.5|https://git.technopunk.space/tomi/Scripts/raw/branch/main/backup/backup.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/backup/backup.conf" SCRIPT_PACKAGES["Backup Suite"]="1.0.5|https://git.technopunk.space/tomi/Scripts/raw/branch/main/backup/backup.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/backup/backup.conf"
SCRIPT_PACKAGES["Monitor Suite"]="1.0.5|https://git.technopunk.space/tomi/Scripts/raw/branch/main/monitor/monitor.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/monitor/monitor.conf" SCRIPT_PACKAGES["Monitor Suite"]="1.0.5|https://git.technopunk.space/tomi/Scripts/raw/branch/main/monitor/monitor.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/monitor/monitor.conf"
SCRIPT_PACKAGES["Key Manager"]="1.2.1|https://git.technopunk.space/tomi/Scripts/raw/branch/main/hdb_keymanager.sh" SCRIPT_PACKAGES["Key Manager"]="1.2.1|https://git.technopunk.space/tomi/Scripts/raw/branch/main/hdb_keymanager.sh"