]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/grant_mysql_privileges.in
Backport from BEE
[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 #
6 #  Bacula® - The Network Backup Solution
7 #
8 #  Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
9 #
10 #  The main author of Bacula is Kern Sibbald, with contributions from many
11 #  others, a complete list can be found in the file AUTHORS.
12 #
13 #  You may use this file and others of this release according to the
14 #  license defined in the LICENSE file, which includes the Affero General
15 #  Public License, v3.0 ("AGPLv3") and some additional permissions and
16 #  terms pursuant to its AGPLv3 Section 7.
17 #
18 #  Bacula® is a registered trademark of Kern Sibbald.
19 #
20 db_user=${db_user:-@db_user@}
21 bindir=@MYSQL_BINDIR@
22 db_name=${db_name:-@db_name@}
23 db_password=@db_password@
24 if [ "$db_password" != "" ]; then
25    pass="identified by '$db_password'"
26 fi
27
28 if $bindir/mysql $* -u root -f <<END-OF-DATA
29 use mysql
30 grant all privileges on ${db_name}.* to ${db_user}@localhost ${pass};
31 grant all privileges on ${db_name}.* to ${db_user}@"%" ${pass};
32 select * from user;
33 flush privileges;
34 END-OF-DATA
35 then
36    echo "Privileges for user ${db_user} granted on database ${db_name}."
37    exit 0
38 else
39    echo "Error creating privileges."
40    exit 1
41 fi