#!/bin/sh
#
# shell script to grant privileges to the bacula database
#
USER=bacula
bindir=
db_name=bacula

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


syntax highlighted by Code2HTML, v. 0.9.1