#!/bin/sh
#
# Copyright (C) 2000-2023 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
#  Drop Bacula database -- works for whatever is configured,
#  MySQL, SQLite, PostgreSQL, Ingres
#

default_db_type=postgresql

#
# 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

echo "Dropping ${db_type} database"
/usr/local/libexec/bacula/drop_${db_type}_database $*
