]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/update_bacula_tables.in
Big backport from Enterprise
[bacula/bacula] / bacula / src / cats / update_bacula_tables.in
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # This routine alters 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
11 pre_command="sh -c"
12
13 default_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 #
19 if [ $# -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
36 fi
37
38 #
39 # If no new db_type is gives use the default db_type.
40 #
41 if [ -z "${db_type}" ]; then
42    db_type="${default_db_type}"
43 fi
44
45 if [ $db_type = postgresql -a "$UID" = 0 ]; then
46     pre_command="su - postgres -c"
47 fi
48
49 echo "Altering ${db_type} tables"
50 $pre_command "@scriptdir@/update_${db_type}_tables $*"