Modifying mysql.sh add support of installation on a remote sql server
This commit is contained in:
parent
5ccb3558b9
commit
249f24658e
|
@ -59,41 +59,56 @@ CREATE DATABASE IF NOT EXISTS $database; "
|
||||||
grant_mail="GRANT ALL ON $database.dovecot_view TO '$alternc_mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$alternc_mail_password';"
|
grant_mail="GRANT ALL ON $database.dovecot_view TO '$alternc_mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$alternc_mail_password';"
|
||||||
grant_mail=$grant_mail"GRANT SELECT ON $database.* TO '$alternc_mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$alternc_mail_password';"
|
grant_mail=$grant_mail"GRANT SELECT ON $database.* TO '$alternc_mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$alternc_mail_password';"
|
||||||
|
|
||||||
echo -n "Trying debian.cnf: "
|
|
||||||
mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf"
|
#if mysql_client != localhost means we are connecting to a remote server
|
||||||
# If this call fail, we may be connected to a mysql-server version 5.0.
|
#the remote sql use rshould already be configured but it is a way of confirming it.
|
||||||
# In that case, change mysql parameters and retry. Use root / nopassword.
|
if [ $MYSQL_CLIENT != "localhost" ]; then
|
||||||
if ! $mysql <<EOF
|
mysql="/usr/bin/mysql -h$host -u$user -p$password"
|
||||||
|
if ! $mysql << EOF
|
||||||
$grant
|
$grant
|
||||||
EOF
|
EOF
|
||||||
then
|
then
|
||||||
echo "failed: debian-sys-maintainer doesn't have the right credentials"
|
echo "Fail"
|
||||||
echo -n "are we doing an upgrade? "
|
echo "Can't grant to remote system user $user, aborting";
|
||||||
mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG"
|
exit 1
|
||||||
if ! $mysql <<EOF
|
fi
|
||||||
$grant
|
else
|
||||||
|
echo -n "Trying debian.cnf: "
|
||||||
|
mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf"
|
||||||
|
# If this call fail, we may be connected to a mysql-server version 5.0.
|
||||||
|
# In that case, change mysql parameters and retry. Use root / nopassword.
|
||||||
|
if ! $mysql <<EOF
|
||||||
|
$grant
|
||||||
EOF
|
EOF
|
||||||
then
|
then
|
||||||
echo "No"
|
echo "failed: debian-sys-maintainer doesn't have the right credentials"
|
||||||
echo -n "Assuming clean install (empty root password)... "
|
echo -n "are we doing an upgrade? "
|
||||||
mysql="/usr/bin/mysql -h$host -uroot "
|
mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG"
|
||||||
if ! $mysql <<EOF
|
if ! $mysql <<EOF
|
||||||
$grant
|
$grant
|
||||||
EOF
|
EOF
|
||||||
then
|
then
|
||||||
echo "Failed"
|
echo "No"
|
||||||
echo -n "Assuming pre 0.9.8 version... "
|
echo -n "Assuming clean install (empty root password)... "
|
||||||
mysql="/usr/bin/mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS"
|
mysql="/usr/bin/mysql -h$host -uroot "
|
||||||
if ! $mysql <<EOF
|
if ! $mysql <<EOF
|
||||||
$grant
|
$grant
|
||||||
EOF
|
EOF
|
||||||
then
|
then
|
||||||
echo "No."
|
echo "Failed"
|
||||||
echo "Can't grant system user $user, aborting";
|
echo -n "Assuming pre 0.9.8 version... "
|
||||||
exit 1
|
mysql="/usr/bin/mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS"
|
||||||
fi
|
if ! $mysql <<EOF
|
||||||
fi
|
$grant
|
||||||
fi
|
EOF
|
||||||
|
then
|
||||||
|
echo "No."
|
||||||
|
echo "Can't grant system user $user, aborting";
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "ok!"
|
echo "ok!"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue