#!/usr/bin/env bash
auralis_db_conf="/etc/auralis/conf.d/database"
if [ -f "$auralis_db_conf" ]; then
    . "$auralis_db_conf"
    echo "$DBPASS" > /etc/mysql-auralis.secret
    mysql -p$(cat /etc/mysql.secret) <<-EOF
    GRANT ALL ON auralis.* TO 'auralis'@'%' IDENTIFIED BY '$DBPASS';
EOF
fi
if [ -f "/etc/apache2/sites-enabled/auralis" ]; then
    a2dissite auralis
    invoke-rc.d apache2 restart
fi

exit 0
