]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/grant_mysql_privileges.in
ab85680ade1b2af6d40db16a739cbacfe08651b3
[bacula/bacula] / bacula / src / cats / grant_mysql_privileges.in
1 #!/bin/sh
2 #
3 # shell script to grant privileges to the bacula database
4 #
5 # Copyright (C) 2000-2015 Kern Sibbald
6 # License: BSD 2-Clause; see file LICENSE-FOSS
7 #
8 db_user=${db_user:-@db_user@}
9 bindir=@MYSQL_BINDIR@
10 db_name=${db_name:-@db_name@}
11 db_password=@db_password@
12 if [ "$db_password" != "" ]; then
13    pass="identified by '$db_password'"
14 fi
15 db_ssl_options=@db_ssl_options@
16 if [ "$db_ssl_options" != "" ]; then
17    ssl_options="require $db_ssl_options"
18 fi
19  
20 if $bindir/mysql $* -u root -f <<END-OF-DATA
21 use mysql
22 grant all privileges on ${db_name}.* to ${db_user}@localhost ${pass} ${ssl_options};
23 grant all privileges on ${db_name}.* to ${db_user}@"%" ${pass} ${ssl_options};
24 select * from user;
25 flush privileges;
26 END-OF-DATA
27 then
28    echo "Privileges for user ${db_user} granted on database ${db_name}."
29    exit 0
30 else
31    echo "Error creating privileges."
32    exit 1
33 fi