]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/update_bacula_tables.in
Big backport from Enterprise
[bacula/bacula] / bacula / src / cats / update_bacula_tables.in
index 943c3109df2fdb7710577c29513185ed9a7491cb..cafeaa178fe672555c4ab04faf7e2936df988fde 100755 (executable)
@@ -1,9 +1,15 @@
 #!/bin/sh
 #
+# Copyright (C) 2000-2017 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
 # This routine alters the appropriately configured
 # Bacula tables for PostgreSQL, Ingres, MySQL, or SQLite.
 #
 
+# can be used to change the current user with su
+pre_command="sh -c"
+
 default_db_type=@DEFAULT_DB_TYPE@
 
 #
@@ -24,10 +30,6 @@ if [ $# -gt 0 ]; then
        db_type=$1
        shift
        ;;
-     ingres)
-       db_type=$1
-       shift
-       ;;
      *)
        ;;
    esac
@@ -40,5 +42,9 @@ if [ -z "${db_type}" ]; then
    db_type="${default_db_type}"
 fi
 
+if [ $db_type = postgresql -a "$UID" = 0 ]; then
+    pre_command="su - postgres -c"
+fi
+
 echo "Altering ${db_type} tables"
-@scriptdir@/update_${db_type}_tables $*
+$pre_command "@scriptdir@/update_${db_type}_tables $*"