Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/mysql/versions/5.6/install.sh

129 lines
3.0 KiB

6 years ago
# -*- coding: utf-8 -*-
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#https://dev.mysql.com/downloads/mysql/5.6.html
#https://dev.mysql.com/downloads/file/?id=489600
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
4 years ago
sysName=`uname`
6 years ago
install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql
3 years ago
6 years ago
Install_mysql()
{
mkdir -p ${mysqlDir}
echo '正在安装脚本文件...' > $install_tmp
if id mysql &> /dev/null ;then
echo "mysql UID is `id -u www`"
echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
else
groupadd mysql
useradd -g mysql mysql
fi
4 years ago
if [ "$sysName" != "Darwin" ];then
mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
fi
3 years ago
# ----- cpu start ------
if [ -z "${cpuCore}" ]; then
cpuCore="1"
fi
3 years ago
if [ -f /proc/cpuinfo ];then
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l`
fi
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
3 years ago
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
3 years ago
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
cpuCore="${MEM_INFO}"
fi
else
cpuCore="1"
fi
if [ "$cpuCore" -gt "1" ];then
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
fi
3 years ago
# ----- cpu end ------
4 years ago
6 years ago
if [ ! -f ${mysqlDir}/mysql-5.6.50.tar.gz ];then
3 years ago
wget -O ${mysqlDir}/mysql-5.6.50.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
6 years ago
fi
if [ ! -d ${mysqlDir}/mysql-5.6.50 ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-5.6.50.tar.gz
6 years ago
fi
OPTIONS=''
##check openssl version
OPENSSL_VERSION=`openssl version|awk '{print $2}'|awk -F '.' '{print $1}'`
if [ "${OPENSSL_VERSION}" -ge "3" ];then
#openssl version to high
3 years ago
cd ${rootPath}/plugins/php/lib && /bin/bash openssl.sh
export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl"
fi
6 years ago
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-5.6.50 && cmake \
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DENABLE_DOWNLOADS=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
$OPTIONS \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DCMAKE_CXX_STANDARD=11
make -j${cpuCore} && make install && make clean
3 years ago
if [ -d $serverPath/mysql ];then
echo '5.6' > $serverPath/mysql/version.pl
echo '安装完成' > $install_tmp
else
3 years ago
# rm -rf ${mysqlDir}/mysql-5.6.50
3 years ago
echo '安装失败' > $install_tmp
3 years ago
echo 'install fail'>&2
3 years ago
exit 1
3 years ago
fi
fi
6 years ago
}
Uninstall_mysql()
{
rm -rf $serverPath/mysql
echo '卸载完成' > $install_tmp
}
action=$1
3 years ago
if [ "${1}" == "install" ];then
6 years ago
Install_mysql
else
Uninstall_mysql
fi