Browse Source

Added MySQL Install functions

old-stable
gau1991 11 years ago
parent
commit
2c058df929
  1. 22
      src/lib/ee_lib_install_mysql.sh
  2. 10
      src/lib/ee_lib_setup_mysql.sh
  3. 18
      src/lib/ee_lib_variables.sh

22
src/lib/ee_lib_install_mysql.sh

@ -0,0 +1,22 @@
# Install mysql package
ee_lib_install_mysql()
{
# Mysql password only set if mysql is not installed
# if mysql is installed don't set wrong password in ~/.my.cnf
ee_lib_package_check mysql-server
if [ -n $PACKAGE_NAME ]; then
# setting up mysql password
local ee_mysql_auto_pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1)
debconf-set-selections <<< "mysql-server mysql-server/root_password password $ee_mysql_auto_pass"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ee_mysql_auto_pass"
# Generate ~/.my.cnf
echo -e "[client]\nuser=root\npassword=$ee_mysql_auto_pass" > ~/.my.cnf
fi
ee_lib_echo "Installing MySQL, Please Wait..."
$EE_APT_GET install mysql-server mysqltuner percona-toolkit \
|| ee_lib_error "Unable To Install MySQL"
}

10
src/lib/ee_lib_setup_mysql.sh

@ -0,0 +1,10 @@
# Setup mysql
ee_lib_setup_mysql()
{
# personal settings for mysql
ee_lib_echo "Updating MySQL Configuration Files, Please Wait..."
# Decrease mysql wait timeout
sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf
}

18
src/lib/ee_lib_variables.sh

@ -21,3 +21,21 @@ elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then
readonly EE_DEBIAN_VERSION=$(lsb_release -r | awk '{print($2)}' | cut -d'.' -f1) readonly EE_DEBIAN_VERSION=$(lsb_release -r | awk '{print($2)}' | cut -d'.' -f1)
fi fi
# Find php user-name
if [ -f /etc/php5/fpm/pool.d/www.conf ]; then
readonly EE_PHP_USER=$(grep ^user /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2 | cut -d' ' -f2)
else
# At installation time: ee system install
# File /etc/php5/fpm/pool.d/www.conf not present
readonly EE_PHP_USER=www-data
fi
# Findout MySQL login
if [ -f ~/.my.cnf ];then
readonly EE_MYSQL_USER=$(cat ~/.my.cnf | grep user | cut -d'=' -f2)
readonly EE_MYSQL_PASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//')
elif [ -f /root/.my.cnf ];then
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
Loading…
Cancel
Save