1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
Description: Make variables in database scripts easier to manually override
Author: Sven Hartge <sven@svenhartge.de>, Carsten Leonhardt <leo@debian.org>
Last-Update: 2022-03-24
--- a/src/cats/create_mysql_database.in
+++ b/src/cats/create_mysql_database.in
@@ -7,7 +7,7 @@
#
bindir=@MYSQL_BINDIR@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
if $bindir/mysql $* -f <<END-OF-DATA
CREATE DATABASE IF NOT EXISTS ${db_name};
--- a/src/cats/create_sqlite3_database.in
+++ b/src/cats/create_sqlite3_database.in
@@ -8,7 +8,7 @@
bindir=@SQLITE_BINDIR@
PATH=$bindir:$PATH
cd @working_dir@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
sqlite3 $* ${db_name}.db <<END-OF-DATA
END-OF-DATA
--- a/src/cats/delete_catalog_backup.in
+++ b/src/cats/delete_catalog_backup.in
@@ -5,7 +5,7 @@
#
# This script deletes a catalog dump
#
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
rm -f @working_dir@/${db_name}.sql
--- a/src/cats/drop_mysql_database.in
+++ b/src/cats/drop_mysql_database.in
@@ -7,7 +7,7 @@
#
bindir=@MYSQL_BINDIR@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
$bindir/mysql $* -f <<END-OF-DATA
DROP DATABASE ${db_name};
--- a/src/cats/drop_mysql_tables.in
+++ b/src/cats/drop_mysql_tables.in
@@ -6,7 +6,7 @@
# shell script to delete Bacula tables for MySQL
bindir=@MYSQL_BINDIR@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
if $bindir/mysql $* <<END-OF-DATA
USE ${db_name};
--- a/src/cats/drop_postgresql_database.in
+++ b/src/cats/drop_postgresql_database.in
@@ -7,7 +7,7 @@
#
bindir=@POSTGRESQL_BINDIR@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
if $bindir/dropdb ${db_name}
then
--- a/src/cats/drop_postgresql_tables.in
+++ b/src/cats/drop_postgresql_tables.in
@@ -6,7 +6,7 @@
# shell script to delete Bacula tables for PostgreSQL
bindir=@POSTGRESQL_BINDIR@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
$bindir/psql -f - -d ${db_name} $* <<END-OF-DATA 1>/dev/null 2>/dev/null
drop table if exists MalwareMD5;
--- a/src/cats/drop_sqlite3_database.in
+++ b/src/cats/drop_sqlite3_database.in
@@ -4,7 +4,7 @@
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# shell script to drop Bacula SQLite tables
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
cd @working_dir@
rm -rf ${db_name}.db
--- a/src/cats/drop_sqlite3_tables.in
+++ b/src/cats/drop_sqlite3_tables.in
@@ -6,6 +6,6 @@
# shell script to Delete the SQLite Bacula database (same as deleting
# the tables)
#
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
rm -f @working_dir@/${db_name}.db
--- a/src/cats/grant_mysql_privileges.in
+++ b/src/cats/grant_mysql_privileges.in
@@ -8,11 +8,11 @@
db_user=${db_user:-@db_user@}
bindir=@MYSQL_BINDIR@
db_name=${db_name:-@db_name@}
-db_password=@db_password@
+db_password=${db_password:-@db_password@}
if [ "$db_password" != "" ]; then
pass="identified by '$db_password'"
fi
-db_ssl_options=@db_ssl_options@
+db_ssl_options=${db_ssl_options:-@db_ssl_options@}
if [ "$db_ssl_options" != "" ]; then
ssl_options="require $db_ssl_options"
fi
--- a/src/cats/grant_postgresql_privileges.in
+++ b/src/cats/grant_postgresql_privileges.in
@@ -9,7 +9,7 @@ db_user=${db_user:-@db_user@}
bindir=@POSTGRESQL_BINDIR@
PATH="$PATH:$bindir"
db_name=${db_name:-@db_name@}
-db_password=@db_password@
+db_password=${db_password:-@db_password@}
if [ "$db_password" != "" ]; then
pass="password '$db_password'"
fi
--- a/src/cats/make_sqlite3_tables.in
+++ b/src/cats/make_sqlite3_tables.in
@@ -9,7 +9,7 @@
bindir=@SQLITE_BINDIR@
PATH="$bindir:$PATH"
cd @working_dir@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
sqlite3 $* ${db_name}.db <<END-OF-DATA
-- --------------------------------------------------------------
--- a/src/cats/update_mysql_tables.in
+++ b/src/cats/update_mysql_tables.in
@@ -20,7 +20,7 @@ echo " have to run this script multiple
echo " "
bindir=@MYSQL_BINDIR@
PATH="$bindir:$PATH"
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
# Special trick to not do the upgrade from 1015 to 1016 with this script
if [ "$1" = "--stop1015" ]; then
--- a/src/cats/update_postgresql_tables.in
+++ b/src/cats/update_postgresql_tables.in
@@ -16,7 +16,7 @@ echo " "
bindir=@POSTGRESQL_BINDIR@
PATH="$bindir:$PATH"
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
# Special trick to not do the upgrade from 1015 to 1016 with this script
if [ "$1" = "--stop1015" ]; then
--- a/src/cats/update_sqlite3_tables.in
+++ b/src/cats/update_sqlite3_tables.in
@@ -16,7 +16,7 @@ echo " "
bindir=@SQLITE_BINDIR@
PATH="$bindir:$PATH"
cd @working_dir@
-db_name=@db_name@
+db_name=${db_name:-@db_name@}
DBVERSION=`sqlite3 ${db_name}.db <<END
SELECT VersionId FROM Version LIMIT 1;
|