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

#   determine MySQL root password
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=root --password=$password create cacti

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

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

