]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/updatedb/update_bacula_tables.in
Backport from Bacula Enterprise
[bacula/bacula] / bacula / updatedb / update_bacula_tables.in
diff --git a/bacula/updatedb/update_bacula_tables.in b/bacula/updatedb/update_bacula_tables.in
new file mode 100755 (executable)
index 0000000..1249077
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2015 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# This routine alters the appropriately configured
+# Bacula tables for PostgreSQL, Ingres, MySQL, or SQLite.
+#
+
+# can be used to change the current user with su
+pre_command="sh -c"
+
+default_db_type=@DEFAULT_DB_TYPE@
+
+#
+# See if the first argument is a valid backend name.
+# If so the user overrides the default database backend.
+#
+if [ $# -gt 0 ]; then
+   case $1 in
+     sqlite3)
+       db_type=$1
+       shift
+       ;;
+     mysql)
+       db_type=$1
+       shift
+       ;;
+     postgresql)
+       db_type=$1
+       shift
+       ;;
+     *)
+       ;;
+   esac
+fi
+
+#
+# If no new db_type is gives use the default db_type.
+#
+if [ -z "${db_type}" ]; then
+   db_type="${default_db_type}"
+fi
+
+if [ $db_type = postgresql -a "$UID" = 0 ]; then
+    pre_command="su - postgres -c"
+fi
+
+echo "Altering ${db_type} tables"
+$pre_command "@scriptdir@/update_${db_type}_tables $*"