#!/bin/sh # # $Id: mysql.sh,v 1.11 2006/01/11 22:51:28 anarcat Exp $ # ---------------------------------------------------------------------- # AlternC - Web Hosting System # Copyright (C) 2002 by the AlternC Development Team. # http://alternc.org/ # ---------------------------------------------------------------------- # Based on: # Valentin Lacambre's web hosting softwares: http://altern.org/ # ---------------------------------------------------------------------- # LICENSE # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License (GPL) # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # To read the license please visit http://www.gnu.org/copyleft/gpl.html # ---------------------------------------------------------------------- # Original Author of file: Benjamin Sonntag # Purpose of file: Install a fresh new mysql database system # USAGE : "mysql.sh loginroot passroot systemdb" # ---------------------------------------------------------------------- # # This script expects the following environment to exist: # * host # * user # * password # * database # * MYSQL_CLIENT # # XXX: the sed script should be generated here # # So this file should generally be sourced like this: # . /usr/share/alternc/install/mysql.sh # # Those values are used to set the username/passwords... # The grant all is the most important right needed in this script. echo "Granting users..." # cat < $MYSQL_CONFIG < $SED_SCRIPT_NAME < $MYSQL_CONFIG.$$ mv -f $MYSQL_CONFIG.$$ $MYSQL_CONFIG rm -f $SED_SCRIPT_NAME # Now we should be able to use the mysql configuration mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG" echo "Checking for MySQL connectivity" $mysql -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" # Final mysql setup: db schema echo "installing AlternC schema in $database..." $mysql < /usr/share/alternc/install/mysql.sql || echo cannot load database schema