#!/bin/sh
#
-# shell script to grant privileges to the bacula database
+# shell script TO GRANT privileges to the bacula database
#
db_user=${db_user:-@db_user@}
bindir=@SQL_BINDIR@
if sql ${db_name} $* <<END-OF-DATA
-create user ${db_user};
-
-- for tables
-grant all on unsavedfiles to ${db_user};
-grant all on basefiles to ${db_user};
-grant all on jobmedia to ${db_user};
-grant all on file to ${db_user};
-grant all on job to ${db_user};
-grant all on media to ${db_user};
-grant all on client to ${db_user};
-grant all on pool to ${db_user};
-grant all on fileset to ${db_user};
-grant all on path to ${db_user};
-grant all on filename to ${db_user};
-grant all on counters to ${db_user};
-grant all on version to ${db_user};
-grant all on cdimages to ${db_user};
-grant all on mediatype to ${db_user};
-grant all on storage to ${db_user};
-grant all on device to ${db_user};
-grant all on status to ${db_user};
-grant all on location to ${db_user};
-grant all on locationlog to ${db_user};
-grant all on log to ${db_user};
-grant all on jobhisto to ${db_user};
-
--- for sequences on those tables
+GRANT ALL ON TABLE filename TO ${db_user};
+GRANT ALL ON TABLE path TO ${db_user};
+GRANT ALL ON TABLE file TO ${db_user};
+GRANT ALL ON TABLE Job TO ${db_user};
+GRANT ALL ON TABLE JobHisto TO ${db_user};
+GRANT ALL ON TABLE Location TO ${db_user};
+GRANT ALL ON TABLE fileset TO ${db_user};
+GRANT ALL ON TABLE jobmedia TO ${db_user};
+GRANT ALL ON TABLE media TO ${db_user};
+GRANT ALL ON TABLE MediaType TO ${db_user};
+GRANT ALL ON TABLE Storage TO ${db_user};
+GRANT ALL ON TABLE Device TO ${db_user};
+GRANT ALL ON TABLE pool TO ${db_user};
+GRANT ALL ON TABLE client TO ${db_user};
+GRANT ALL ON TABLE Log TO ${db_user};
+GRANT ALL ON TABLE LocationLog TO ${db_user};
+GRANT ALL ON TABLE counters TO ${db_user};
+GRANT ALL ON TABLE basefiles TO ${db_user};
+GRANT ALL ON TABLE unsavedfiles TO ${db_user};
+GRANT ALL ON TABLE CDImages TO ${db_user};
+GRANT ALL ON TABLE PathHierarchy TO ${db_user};
+GRANT ALL ON TABLE PathVisibility TO ${db_user};
+GRANT ALL ON TABLE version TO ${db_user};
+GRANT ALL ON TABLE Status TO ${db_user};
-grant select, update on filename_filenameid_seq to ${db_user};
-grant select, update on path_pathid_seq to ${db_user};
-grant select, update on fileset_filesetid_seq to ${db_user};
-grant select, update on pool_poolid_seq to ${db_user};
-grant select, update on client_clientid_seq to ${db_user};
-grant select, update on media_mediaid_seq to ${db_user};
-grant select, update on job_jobid_seq to ${db_user};
-grant select, update on file_fileid_seq to ${db_user};
-grant select, update on jobmedia_jobmediaid_seq to ${db_user};
-grant select, update on basefiles_baseid_seq to ${db_user};
-grant select, update on storage_storageid_seq to ${db_user};
-grant select, update on mediatype_mediatypeid_seq to ${db_user};
-grant select, update on device_deviceid_seq to ${db_user};
-grant select, update on location_locationid_seq to ${db_user};
-grant select, update on locationlog_loclogid_seq to ${db_user};
-grant select, update on log_logid_seq to ${db_user};
+-- for sequences ON those tables
+GRANT NEXT ON SEQUENCE filename_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE path_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE file_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE Job_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE JobHisto_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE Location_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE fileset_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE jobmedia_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE media_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE MediaType_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE Storage_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE Device_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE pool_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE client_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE Log_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE LocationLog_seq TO ${db_user};
+GRANT NEXT ON SEQUENCE basefiles_seq TO ${db_user};
+\g
END-OF-DATA
then