#!/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@
#
db_type=$1
shift
;;
- ingres)
- db_type=$1
- shift
- ;;
*)
;;
esac
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 $*"