#!/bin/sh
#
# shell script to grant privileges to the bacula database
#
db_user=${db_user:-bacula}
bindir=/usr/local/bin
db_name=${db_name:-bacula}

if $bindir/mysql $* -u root -f <<END-OF-DATA
use mysql
grant all privileges on ${db_name}.* to ${db_user}@localhost;
grant all privileges on ${db_name}.* to ${db_user}@"%";
select * from user;
flush privileges;
END-OF-DATA
then
   echo "Privileges for user ${db_user} granted on database ${db_name}."
   exit 0
else
   echo "Error creating privileges."
   exit 1
fi
