]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/grant_postgresql_privileges.in
1a3b9dbb04ddbbec43e7bb30ea9b30aba1b3a8c8
[bacula/bacula] / bacula / src / cats / grant_postgresql_privileges.in
1 #!/bin/sh
2 #
3 # shell script to grant privileges to the bacula database
4 #
5 USER=bacula
6 bindir=@SQL_BINDIR@
7
8 if $bindir/psql $* bacula -f - <<END-OF-DATA
9
10 create user ${USER};
11
12 -- for tables
13 grant all on unsavedfiles to ${USER};
14 grant all on basefiles    to ${USER};
15 grant all on jobmedia     to ${USER};
16 grant all on file         to ${USER};
17 grant all on job          to ${USER};
18 grant all on media        to ${USER};
19 grant all on client       to ${USER};
20 grant all on pool         to ${USER};
21 grant all on fileset      to ${USER};
22 grant all on path         to ${USER};
23 grant all on filename     to ${USER};
24 grant all on counters     to ${USER};
25 grant all on version      to ${USER};
26
27 -- for sequences on those tables
28
29 grant select, update on filename_filenameid_seq to ${USER};
30 grant select, update on path_pathid_seq         to ${USER};
31 grant select, update on fileset_filesetid_seq   to ${USER};
32 grant select, update on pool_poolid_seq         to ${USER};
33 grant select, update on client_clientid_seq     to ${USER};
34 grant select, update on media_mediaid_seq       to ${USER};
35 grant select, update on job_jobid_seq           to ${USER};
36 grant select, update on file_fileid_seq         to ${USER};
37 grant select, update on jobmedia_jobmediaid_seq to ${USER};
38 grant select, update on basefiles_baseid_seq    to ${USER};
39
40 END-OF-DATA
41 then
42    echo "Privileges for ${USER} granted."
43    exit 0
44 else
45    echo "Error creating privileges."
46    exit 1
47 fi