#!/bin/sh
##
##  cacti-setup
##

#   determine MySQL root password
username=`grep "^user" @l_prefix@/etc/mysql/my.pwd |\
          sed -e 's;^user[^=]*= *;;' -e 's; *$;;'`
password=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\
          sed -e 's;^password[^=]*= *;;' -e 's; *$;;'`

#   create the MySQL database for Cacti
@l_prefix@/bin/mysqladmin --user=$username --password=$password create cacti

#   create the default Cacti database schema
@l_prefix@/bin/mysql --user=$username --password=$password cacti <@l_prefix@/share/cacti/cacti.sql

#   create a MySQL username/password for Cacti
@l_prefix@/bin/mysql --user=$username --password=$password mysql <<EOF
GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cacti';
FLUSH PRIVILEGES;
EOF

