Browse Source

Support for remote mysql #147

old-stable
Mitesh Shah 11 years ago
parent
commit
e9a4a2ff7e
  1. 2
      config/easyengine/ee.conf
  2. 3
      src/lib/ee_lib_mysql_info.sh
  3. 16
      src/lib/ee_lib_variables.sh
  4. 4
      src/modules/site/create/ee_mod_setup_database.sh

2
config/easyengine/ee.conf

@ -6,7 +6,7 @@
ip-address = ip-address =
[mysql] [mysql]
host = localhost client-host = localhost
db-name = false db-name = false
db-user = false db-user = false

3
src/lib/ee_lib_mysql_info.sh

@ -12,8 +12,7 @@ function ee_lib_mysql_info()
local ee_mysql_max_used_connections=$(mysql -e "show global status" | grep Max_used_connections | awk '{print($2)}') local ee_mysql_max_used_connections=$(mysql -e "show global status" | grep Max_used_connections | awk '{print($2)}')
ee_lib_echo ee_lib_echo
ee_lib_echo "MySQL ($ee_mysql_version):" ee_lib_echo "MySQL ($ee_mysql_version) on $EE_MYSQL_HOST:"
ee_lib_echo_escape "user\t\t\t\t \033[37m$EE_MYSQL_USER"
ee_lib_echo_escape "port\t\t\t\t \033[37m$ee_mysql_port" ee_lib_echo_escape "port\t\t\t\t \033[37m$ee_mysql_port"
ee_lib_echo_escape "wait_timeout\t\t\t \033[37m$ee_mysql_wait_timeout" ee_lib_echo_escape "wait_timeout\t\t\t \033[37m$ee_mysql_wait_timeout"
ee_lib_echo_escape "interactive_timeout\t\t \033[37m$ee_mysql_interactive_timeout" ee_lib_echo_escape "interactive_timeout\t\t \033[37m$ee_mysql_interactive_timeout"

16
src/lib/ee_lib_variables.sh

@ -39,17 +39,15 @@ else
fi fi
# Find out MySQL hostname # Find out MySQL hostname
if [ -z $($EE_CONFIG_GET mysql.host) ]; then if [ -z $(git config --file $HOME/.my.cnf client.host) ]; then
readonly EE_MYSQL_HOST=localhost readonly EE_MYSQL_HOST=localhost
else else
readonly EE_MYSQL_HOST=$($EE_CONFIG_GET mysql.host) readonly EE_MYSQL_HOST=$(git config --file $HOME/.my.cnf client.host)
fi fi
# Find out MySQL login # Find out MySQL client-host to setup grants
if [ -f ~/.my.cnf ];then if [ -z $($EE_CONFIG_GET mysql.client-host) ]; then
readonly EE_MYSQL_USER=$(cat ~/.my.cnf | grep user | cut -d'=' -f2) readonly EE_MYSQL_CLIENT_HOST=localhost
readonly EE_MYSQL_PASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//') else
elif [ -f /root/.my.cnf ];then readonly EE_MYSQL_CLIENT_HOST=$($EE_CONFIG_GET mysql.client-host)
readonly EE_MYSQL_USER=$(cat /root/.my.cnf | grep user | cut -d'=' -f2)
readonly EE_MYSQL_PASS=$(cat /root/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//')
fi fi

4
src/modules/site/create/ee_mod_setup_database.sh

@ -56,11 +56,11 @@ function ee_mod_setup_database()
|| ee_lib_error "Unable to create $EE_DB_NAME database, exit status = " $? || ee_lib_error "Unable to create $EE_DB_NAME database, exit status = " $?
# Create MySQL User # Create MySQL User
mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_HOST' identified by '$EE_DB_PASS'" \ mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST' identified by '$EE_DB_PASS'" \
|| ee_lib_error "Unable to create $EE_DB_USER database user, exit status = " $? || ee_lib_error "Unable to create $EE_DB_USER database user, exit status = " $?
# Grant permission # Grant permission
mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_HOST'" \ mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST'" \
|| ee_lib_error "Unable to grant privileges for $EE_DB_USER database user, exit status = " $? || ee_lib_error "Unable to grant privileges for $EE_DB_USER database user, exit status = " $?
mysql -e "flush privileges" mysql -e "flush privileges"
} }

Loading…
Cancel
Save