]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/grant_mysql_privileges.in
Split messages line by line before sending it to syslog() fix #3325
[bacula/bacula] / bacula / src / cats / grant_mysql_privileges.in
index b51561bde7b53e4178f7f1ee653fe40c955777e3..3f315d2380ff73f2a9ec2d945877956d17c1137f 100644 (file)
@@ -1,23 +1,24 @@
 #!/bin/sh
 #
-# shell script to create Bacula database(s)
+# shell script to grant privileges to the bacula database
 #
-
-bindir=@SQL_BINDIR@
+db_user=${db_user:-@db_user@}
+bindir=@MYSQL_BINDIR@
+db_name=${db_name:-@db_name@}
+db_password=@db_password@
+if [ "$db_password" != "" ]; then
+   pass="identified by '$db_password'"
+fi
 
 if $bindir/mysql $* -u root -f <<END-OF-DATA
 use mysql
-grant all privileges on *.* to kern@localhost with grant option;
-grant all privileges on *.* to kern@"%" with grant option;
-grant all privileges on *.* to kelvin@localhost with grant option;
-grant all privileges on *.* to kelvin@"%" with grant option;
-grant all privileges on *.* to bacula@localhost with grant option;
-grant all privileges on *.* to bacula@"%" with grant option;
+grant all privileges on ${db_name}.* to ${db_user}@localhost ${pass};
+grant all privileges on ${db_name}.* to ${db_user}@"%" ${pass};
 select * from user;
 flush privileges;
 END-OF-DATA
 then
-   echo "Privileges for kern, kelvin, and bacula granted."
+   echo "Privileges for user ${db_user} granted on database ${db_name}."
    exit 0
 else
    echo "Error creating privileges."