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.5/install.sh

175 lines
4.6 KiB

7 years ago
#!/bin/bash
2 years ago
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
7 years ago
export PATH
6 years ago
#https://dev.mysql.com/downloads/mysql/5.5.html#downloads
#https://dev.mysql.com/downloads/file/?id=480541
7 years ago
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
4 years ago
sysName=`uname`
10 months ago
sysArch=`arch`
7 years ago
6 years ago
mysqlDir=${serverPath}/source/mysql
7 years ago
2 years ago
VERSION=5.5.62
3 years ago
10 months ago
_os=`uname`
echo "use system: ${_os}"
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eq "openSUSE" /etc/*-release; then
OSNAME='opensuse'
zypper refresh
elif grep -Eq "FreeBSD" /etc/*-release; then
OSNAME='freebsd'
pkg install -y wget unzip
elif grep -Eqi "Arch" /etc/issue || grep -Eq "Arch" /etc/*-release; then
OSNAME='arch'
echo y | pacman -Sy unzip
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
yum install -y wget zip unzip
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
yum install -y wget zip unzip
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
OSNAME='rocky'
yum install -y wget zip unzip
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
OSNAME='alma'
yum install -y wget zip unzip
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
apt update -y
apt install -y devscripts
apt install -y wget zip unzip
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
apt install -y wget zip unzip
else
OSNAME='unknow'
fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
7 years ago
Install_mysql()
{
6 years ago
mkdir -p ${mysqlDir}
5 months ago
echo '正在安装脚本文件...'
7 years ago
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 "2" ];then
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
else
cpuCore="1"
fi
3 years ago
# ----- cpu end ------
6 years ago
2 years ago
if [ ! -f ${mysqlDir}/mysql-${VERSION}.tar.gz ];then
wget --no-check-certificate -O ${mysqlDir}/mysql-${VERSION}.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-${VERSION}.tar.gz
6 years ago
fi
2 years ago
if [ ! -d ${mysqlDir}/mysql-${VERSION} ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-${VERSION}.tar.gz
7 years ago
fi
6 years ago
WHERE_DIR_GCC=/usr/bin/gcc
WHERE_DIR_GPP=/usr/bin/g++
if [ ! -f $WHERE_DIR_GCC ];then
WHERE_DIR_GCC=`which gcc`
fi
if [ ! -f $WHERE_DIR_GPP ];then
WHERE_DIR_GPP=`which g++`
fi
7 years ago
10 months ago
# https://blog.whsir.com/post-7748.html
# arm架构编译MySQL5.5报错
if [[ "$sysArch" =~ "aarch" ]];then
# wget --no-check-certificate -O ${mysqlDir}/mysql-5.5-fix-arm-client_plugin.patch https://down.whsir.com/downloads/mysql-5.5-fix-arm-client_plugin.patch
cd ${mysqlDir}/mysql-5.5.62 && patch -p1 < ${rootPath}/plugins/mysql/patch/mysql-5.5-fix-arm-client_plugin.patch
fi
10 months ago
if [ "$OSNAME" == "ubuntu" ];then
apt install -y libudev-dev
apt install -y libtirpc-dev
apt install -y libssl-dev
apt install -y libgssglue-dev
apt install -y software-properties-common
add-apt-repository -y ppa:ubuntu-toolchain-r/test
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
10 months ago
apt install -y gcc-10 g++-10
WHERE_DIR_GCC=/usr/bin/gcc-10
WHERE_DIR_GPP=/usr/bin/g++-10
10 months ago
fi
6 years ago
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-5.5.62 && 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 \
-DEXTRA_CHARSETS=all \
3 years ago
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DCMAKE_C_COMPILER=$WHERE_DIR_GCC \
-DCMAKE_CXX_COMPILER=$WHERE_DIR_GPP
make -j${cpuCore} && make install && make clean
3 years ago
if [ -d $serverPath/mysql ];then
rm -rf ${mysqlDir}/mysql-${VERSION}
3 years ago
echo '5.5' > $serverPath/mysql/version.pl
2 years ago
echo "${VERSION}安装完成"
3 years ago
else
3 years ago
# rm -rf ${mysqlDir}/mysql-5.5.62
2 years ago
echo "${VERSION}安装失败"
3 years ago
exit 1
3 years ago
fi
6 years ago
fi
7 years ago
}
Uninstall_mysql()
{
rm -rf $serverPath/mysql
5 months ago
echo '卸载完成'
7 years ago
}
action=$1
3 years ago
if [ "${1}" == "install" ];then
7 years ago
Install_mysql
else
Uninstall_mysql
fi