]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/drop_bacula_tables.in
Real fix of bug #1897
[bacula/bacula] / bacula / src / cats / drop_bacula_tables.in
index 459d504661f2ad3ebb3e9c60182ede863fccf7ae..f3534167bff11655eb2d092cc1806f576cc054e7 100755 (executable)
@@ -1,23 +1,44 @@
 #!/bin/sh
 #
 #  Drop Bacula tables -- works for whatever is configured,
-#    MySQL, SQLite, Ingres, or PostgreSQL
+#  MySQL, SQLite, Ingres, or PostgreSQL
 #
-if test xsqlite3 = x@DB_TYPE@ ; then
-  @scriptdir@/drop_@DB_TYPE@_tables $*
-  echo "Dropped SQLite tables"
-else
-  if test xmysql = x@DB_TYPE@ ; then 
-    echo "Making MySQL tables"
-    @scriptdir@/drop_mysql_tables $*
-    echo "Dropped MySQL tables"
-  elif test xingres = x@DB_TYPE@ ; then
-    echo "Dropping Ingres tables"
-    @scriptdir@/drop_ingres_tables $*
-    echo "Dropped Ingres tables"
-  else
-    # hardcoded database name - should be a parameter
-    @scriptdir@/drop_postgresql_tables $*
-    echo "Dropped PostgreSQL tables"
-  fi
+
+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
+       ;;
+     ingres)
+       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
+
+@scriptdir@/drop_${db_type}_tables $*
+echo "Dropped ${db_type} tables"