3 # shell script to grant privileges to the bacula database
5 db_user=${db_user:-@db_user@}
7 db_name=${db_name:-@db_name@}
8 db_password=@db_password@
9 if [ "$db_password" != "" ]; then
10 pass="password '$db_password'"
14 $bindir/psql -f - -d ${db_name} $* <<END-OF-DATA
16 create user ${db_user} ${pass};
19 grant all on unsavedfiles to ${db_user};
20 grant all on basefiles to ${db_user};
21 grant all on jobmedia to ${db_user};
22 grant all on file to ${db_user};
23 grant all on job to ${db_user};
24 grant all on media to ${db_user};
25 grant all on client to ${db_user};
26 grant all on pool to ${db_user};
27 grant all on fileset to ${db_user};
28 grant all on path to ${db_user};
29 grant all on filename to ${db_user};
30 grant all on counters to ${db_user};
31 grant all on version to ${db_user};
32 grant all on cdimages to ${db_user};
33 grant all on mediatype to ${db_user};
34 grant all on storage to ${db_user};
35 grant all on device to ${db_user};
36 grant all on status to ${db_user};
37 grant all on location to ${db_user};
38 grant all on locationlog to ${db_user};
39 grant all on log to ${db_user};
40 grant all on jobhisto to ${db_user};
41 grant all on PathHierarchy to ${db_user};
42 grant all on PathVisibility to ${db_user};
43 grant all on RestoreObject to ${db_user};
44 -- for sequences on those tables
46 grant select, update on filename_filenameid_seq to ${db_user};
47 grant select, update on path_pathid_seq to ${db_user};
48 grant select, update on fileset_filesetid_seq to ${db_user};
49 grant select, update on pool_poolid_seq to ${db_user};
50 grant select, update on client_clientid_seq to ${db_user};
51 grant select, update on media_mediaid_seq to ${db_user};
52 grant select, update on job_jobid_seq to ${db_user};
53 grant select, update on file_fileid_seq to ${db_user};
54 grant select, update on jobmedia_jobmediaid_seq to ${db_user};
55 grant select, update on basefiles_baseid_seq to ${db_user};
56 grant select, update on storage_storageid_seq to ${db_user};
57 grant select, update on mediatype_mediatypeid_seq to ${db_user};
58 grant select, update on device_deviceid_seq to ${db_user};
59 grant select, update on location_locationid_seq to ${db_user};
60 grant select, update on locationlog_loclogid_seq to ${db_user};
61 grant select, update on log_logid_seq to ${db_user};
62 grant select, update on restoreobject_restoreobjectid_seq to ${db_user};
66 echo "Privileges for user ${db_user} granted on database ${db_name}."
69 echo "Error creating privileges."