1#!/bin/sh
2#
3# Copyright (C) 2000-2017 Kern Sibbald
4# License: BSD 2-Clause; see file LICENSE-FOSS
5#
6# This routine makes the appropriately configured
7# Bacula tables for PostgreSQL, Ingres, MySQL, or SQLite.
8#
9
10# can be used to change the current user with su
11pre_command="sh -c"
12
13default_db_type=@DEFAULT_DB_TYPE@
14
15#
16# See if the first argument is a valid backend name.
17# If so the user overrides the default database backend.
18#
19if [ $# -gt 0 ]; then
20   case $1 in
21     sqlite3)
22       db_type=$1
23       shift
24       ;;
25     mysql)
26       db_type=$1
27       shift
28       ;;
29     postgresql)
30       db_type=$1
31       shift
32       ;;
33     *)
34       ;;
35   esac
36fi
37
38#
39# If no new db_type is gives use the default db_type.
40#
41if [ -z "${db_type}" ]; then
42   db_type="${default_db_type}"
43fi
44
45if [ $db_type = postgresql -a "$UID" = 0 ]; then
46    pre_command="su - postgres -c"
47fi
48
49echo "Making ${db_type} tables"
50$pre_command "@scriptdir@/make_${db_type}_tables $*"
51