Now we use MYSQL_HOST in mysql.sh. Should work with remote mysqld. Updates #1013 (to be tested though)

This commit is contained in:
Benjamin Sonntag 2007-08-23 08:24:15 +00:00
parent 8467cf5473
commit 5f59a52a6f
2 changed files with 13 additions and 12 deletions

View File

@ -155,10 +155,10 @@ tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES
###################################################################### ######################################################################
# Initialize database # Initialize database
# #
if [ -e /usr/sbin/mysqld ]; then #if [ -e /usr/sbin/mysqld ]; then
echo "Setup MySQL and database..." echo "Setup MySQL and database..."
/usr/share/alternc/install/mysql.sh "$MYSQL_USER" "$MYSQL_PASS" "$MYSQL_DATABASE" /usr/share/alternc/install/mysql.sh "$MYSQL_HOST" "$MYSQL_USER" "$MYSQL_PASS" "$MYSQL_DATABASE"
fi #fi
######################################################################## ########################################################################
# Ad-hoc fixes # Ad-hoc fixes

View File

@ -29,22 +29,23 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# #
rootlogin="$1" sqlserver="$1"
rootpass="$2" rootlogin="$2"
systemdb="$3" rootpass="$3"
systemdb="$4"
if [ -z "$rootlogin" -o -z "$rootpass" -o -z "$systemdb" ] if [ -z "$rootlogin" -o -z "$rootpass" -o -z "$systemdb" ]
then then
echo "Usage: mysql.sh <rootlogin> <rootpass> <systemdb>" echo "Usage: mysql.sh <mysqlserver> <rootlogin> <rootpass> <systemdb>"
exit 1 exit 1
fi fi
mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf -h$sqlserver "
if ! $mysql mysql -e "SHOW TABLES" >/dev/null if ! $mysql mysql -e "SHOW TABLES" >/dev/null
then then
# is this an upgrade then? # is this an upgrade then?
mysql="/usr/bin/mysql -u$rootlogin -p$rootpass" mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass"
if ! $mysql mysql -e "SHOW TABLES" >/dev/null if ! $mysql mysql -e "SHOW TABLES" >/dev/null
then then
echo "Can't get proper credentials, aborting" echo "Can't get proper credentials, aborting"
@ -60,7 +61,7 @@ $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$ro
if [ "$?" -ne "0" ] if [ "$?" -ne "0" ]
then then
echo "You are using mysql 5.0, so we try with root account and no password since debian-sys-maint doesn't work." echo "You are using mysql 5.0, so we try with root account and no password since debian-sys-maint doesn't work."
mysql="/usr/bin/mysql -uroot " mysql="/usr/bin/mysql -h$sqlserver -uroot "
echo "Granting users " echo "Granting users "
$mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION"
if [ "$?" -ne "0" ] if [ "$?" -ne "0" ]
@ -71,7 +72,7 @@ then
fi fi
# Now we can use rootlogin and rootpass. # Now we can use rootlogin and rootpass.
mysql="/usr/bin/mysql -u$rootlogin -p$rootpass" mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass"
echo "Setting AlternC '$systemdb' system table and privileges " echo "Setting AlternC '$systemdb' system table and privileges "
$mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;" $mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;"
@ -79,4 +80,4 @@ $mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;"
echo "Installing AlternC schema " echo "Installing AlternC schema "
$mysql $systemdb < /usr/share/alternc/install/mysql.sql $mysql $systemdb < /usr/share/alternc/install/mysql.sql
/usr/bin/mysql -u$rootlogin -p$rootpass $systemdb -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" /usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass $systemdb -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!"