#!/bin/sh
#
# This routine alters the appropriately configured
# Bacula tables for PostgreSQL, Ingres, MySQL, or SQLite.
#
#
#  Bacula® - The Network Backup Solution
#
#  Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
#
#  The main author of Bacula is Kern Sibbald, with contributions from many
#  others, a complete list can be found in the file AUTHORS.
#
#  You may use this file and others of this release according to the
#  license defined in the LICENSE file, which includes the Affero General
#  Public License, v3.0 ("AGPLv3") and some additional permissions and
#  terms pursuant to its AGPLv3 Section 7.
#
#  Bacula® is a registered trademark of Kern Sibbald.
#

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

echo "Altering ${db_type} tables"
/usr/local/libexec/bacula/update_${db_type}_tables $*
