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/scripts/lib.sh

417 lines
13 KiB

7 years ago
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
7 years ago
curPath=`pwd`
rootPath=$(dirname "$curPath")
serverPath=$(dirname "$rootPath")
7 years ago
sourcePath=$serverPath/source/lib
7 years ago
libPath=$serverPath/lib
7 years ago
7 years ago
mkdir -p $sourcePath
7 years ago
mkdir -p $libPath
7 years ago
rm -rf ${libPath}/lib.pl
7 years ago
7 years ago
Install_Zlib()
7 years ago
{
7 years ago
#----------------------------- zlib start -------------------------#
if [ ! -d ${libPath}/zlib ];then
cd ${sourcePath}
if [ ! -f ${sourcePath}/zlib-1.2.11.tar.gz ];then
wget -O zlib-1.2.11.tar.gz https://github.com/madler/zlib/archive/v1.2.11.tar.gz -T 20
fi
tar -zxf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=${libPath}/zlib && make && make install
fi
echo -e "Install_Zlib" >> ${libPath}/lib.pl
#----------------------------- zlib end -------------------------#
7 years ago
}
6 years ago
Install_Libzip()
{
#----------------------------- libzip start -------------------------#
if [ ! -d ${libPath}/libzip ];then
cd ${sourcePath}
3 years ago
if [ ! -f ${sourcePath}/libzip-1.3.2.tar.gz ];then
3 years ago
wget -O libzip-1.3.2.tar.gz --no-check-certificate https://nih.at/libzip/libzip-1.3.2.tar.gz -T 20
6 years ago
fi
3 years ago
tar -zxf libzip-1.3.2.tar.gz
cd libzip-1.3.2
6 years ago
./configure --prefix=${libPath}/libzip && make && make install
fi
echo -e "Install_Libzip" >> ${libPath}/lib.pl
#----------------------------- libzip end -------------------------#
}
Install_Libmemcached()
{
#----------------------------- libmemcached start -------------------------#
if [ ! -d ${libPath}/libmemcached ];then
cd ${sourcePath}
if [ ! -f ${sourcePath}/libmemcached-1.0.4.tar.gz ];then
wget -O libmemcached-1.0.4.tar.gz https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz -T 20
fi
tar -zxf libmemcached-1.0.4.tar.gz
cd libmemcached-1.0.4
5 years ago
./configure --prefix=${libPath}/libmemcached -with-memcached && make && make install
fi
echo -e "Install_Libmemcached" >> ${libPath}/lib.pl
#----------------------------- libmemcached end -------------------------#
}
6 years ago
7 years ago
Install_Libiconv()
{
6 years ago
#----------------------------- libiconv start -------------------------#
3 years ago
cd ${sourcePath}
if [ ! -d ${libPath}/libiconv ];then
# wget -O libiconv-1.15.tar.gz https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz -T 5
wget -O libiconv-1.15.tar.gz https://github.com/midoks/mdserver-web/releases/download/init/libiconv-1.15.tar.gz -T 5
tar zxvf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=${libPath}/libiconv --enable-static
make && make install
cd ${sourcePath}
rm -rf libiconv-1.15
rm -rf libiconv-1.15.tar.gz
3 years ago
fi
echo -e "Install_Libiconv" >> ${libPath}/lib.pl
6 years ago
#----------------------------- libiconv end -------------------------#
7 years ago
}
6 years ago
Install_Freetype()
{
3 years ago
#----------------------------- freetype start -------------------------#
3 years ago
cd ${sourcePath}
if [ ! -d ${libPath}/freetype_old ];then
wget -O freetype-2.7.1.tar.gz --no-check-certificate https://download.savannah.gnu.org/releases/freetype/freetype-2.7.1.tar.gz -T 5
tar zxvf freetype-2.7.1.tar.gz
cd freetype-2.7.1
./configure --prefix=${libPath}/freetype_old
make && make install
3 years ago
cd ${sourcePath}
3 years ago
rm -rf freetype-2.7.1.tar.gz
rm -rf freetype-2.7.1
3 years ago
fi
echo -e "Install_Freetype_Old" >> ${libPath}/lib.pl
3 years ago
#----------------------------- freetype end -------------------------#
}
Install_Freetype_New()
{
6 years ago
#----------------------------- freetype start -------------------------#
3 years ago
cd ${sourcePath}
if [ ! -d ${libPath}/freetype ];then
wget -O freetype-2.12.1.tar.gz --no-check-certificate https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.gz -T 5
tar zxvf freetype-2.12.1.tar.gz
cd freetype-2.12.1
./configure --prefix=${libPath}/freetype
make && make install
6 years ago
cd ${sourcePath}
3 years ago
rm -rf freetype-2.12.1.tar.gz
rm -f freetype-2.12.1.tar.gz
fi
echo -e "Install_Freetype" >> ${libPath}/lib.pl
6 years ago
#----------------------------- freetype end -------------------------#
}
7 years ago
Install_Libmcrypt()
{
3 years ago
#----------------------------- libmcrypt start -------------------------#
if [ -f '/usr/local/lib/libmcrypt.so' ];then
return;
fi
cd ${run_path}
if [ ! -f "libmcrypt-2.5.8.tar.gz" ];then
wget -O libmcrypt-2.5.8.tar.gz ${download_Url}/src/libmcrypt-2.5.8.tar.gz -T 5
fi
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
ln -sf /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -sf /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ldconfig
cd ${run_path}
rm -rf libmcrypt-2.5.8
rm -f libmcrypt-2.5.8.tar.gz
echo -e "Install_Libmcrypt" >> /www/server/lib.pl
#----------------------------- libmcrypt start -------------------------#
7 years ago
}
Install_Mcrypt()
{
if [ -f '/usr/bin/mcrypt' ] || [ -f '/usr/local/bin/mcrypt' ];then
return;
fi
cd ${run_path}
if [ ! -f "mcrypt-2.6.8.tar.gz" ];then
wget -O mcrypt-2.6.8.tar.gz ${download_Url}/src/mcrypt-2.6.8.tar.gz -T 5
fi
tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure
make && make install
cd ${run_path}
rm -rf mcrypt-2.6.8
rm -f mcrypt-2.6.8.tar.gz
echo -e "Install_Mcrypt" >> /www/server/lib.pl
}
Install_Pcre()
{
Cur_Pcre_Ver=`pcre-config --version|grep '^8.' 2>&1`
if [ "$Cur_Pcre_Ver" == "" ];then
pcre_version=8.40
wget -O pcre-$pcre_version.tar.gz ${download_Url}/src/pcre-$pcre_version.tar.gz -T 5
tar zxf pcre-$pcre_version.tar.gz
cd pcre-$pcre_version
if [ "$Is_64bit" == "64" ];then
./configure --prefix=/usr --docdir=/usr/share/doc/pcre-$pcre_version --libdir=/usr/lib64 --enable-unicode-properties --enable-pcre16 --enable-pcre32 --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-pcretest-libreadline --disable-static --enable-utf8
else
./configure --prefix=/usr --docdir=/usr/share/doc/pcre-$pcre_version --enable-unicode-properties --enable-pcre16 --enable-pcre32 --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-pcretest-libreadline --disable-static --enable-utf8
fi
make && make install
cd ..
rm -rf pcre-$pcre_version
rm -f pcre-$pcre_version.tar.gz
fi
}
Install_OpenSSL()
{
7 years ago
if [ ! -d ${libPath}/openssl ];then
7 years ago
cd ${sourcePath}
7 years ago
if [ ! -f ${sourcePath}/openssl-1.0.2q.tar.gz ];then
7 years ago
wget https://github.com/midoks/mdserver-web/releases/download/init/openssl-1.0.2q.tar.gz -T 20
fi
tar -zxf openssl-1.0.2q.tar.gz
cd openssl-1.0.2q
./config --openssldir=${libPath}/openssl zlib-dynamic shared
7 years ago
make && make install
fi
7 years ago
echo -e "Install_OpenSSL" >> ${libPath}/lib.pl
7 years ago
}
7 years ago
6 years ago
Install_Curl()
{
#----------------------------- curl start -------------------------#
3 years ago
6 years ago
if [ ! -d ${libPath}/curl ];then
cd ${sourcePath}
if [ ! -f ${sourcePath}/curl-7.64.0.tar.gz ];then
wget https://curl.haxx.se/download/curl-7.64.0.tar.gz -T 20
fi
tar -zxf curl-7.64.0.tar.gz
cd curl-7.64.0
./configure --prefix=${libPath}/curl --with-ssl=${libPath}/openssl
make && make install
fi
echo -e "Install_Curl" >> ${libPath}/lib.pl
#----------------------------- curl end -------------------------#
}
5 years ago
3 years ago
if grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
sudo ln -sf /bin/bash /bin/sh
#sudo dpkg-reconfigure dash
fi
3 years ago
_os=`uname`
3 years ago
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
3 years ago
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
OSNAME='rocky'
3 years ago
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
OSNAME='rhel'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
OSNAME='aliyun'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Amazon Linux AMI" /etc/issue || grep -Eq "Amazon Linux AMI" /etc/*-release; then
OSNAME='amazon'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
OSNAME='raspbian'
elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
OSNAME='deepin'
else
OSNAME='unknow'
fi
3 years ago
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
echo "${OSNAME}:${VERSION_ID}"
6 years ago
3 years ago
# system judge
3 years ago
if [ "$OSNAME" == "macos" ]; then
5 years ago
brew install libmemcached
brew install curl
brew install zlib
brew install freetype
brew install openssl
brew install libzip
3 years ago
3 years ago
elif [ "$OSNAME" == "ubuntu" ] || [ "$OSNAME" == "debian" ]; then
3 years ago
apt install -y devscripts
3 years ago
apt install -y net-tools
3 years ago
apt install -y python3-dev
3 years ago
apt install -y autoconf
3 years ago
apt install -y gcc
3 years ago
3 years ago
apt install -y libffi-dev
3 years ago
apt install -y cmake automake make
3 years ago
3 years ago
apt install -y webp scons
3 years ago
apt install -y libwebp-dev
apt install -y lzma lzma-dev
apt install -y libunwind-dev
3 years ago
3 years ago
apt install -y libpcre3 libpcre3-dev
3 years ago
apt install -y openssl
3 years ago
apt install -y libssl-dev
3 years ago
3 years ago
apt install -y libmemcached-dev
3 years ago
apt install -y libsasl2-dev
3 years ago
apt install -y imagemagick libmagickwand-dev
3 years ago
3 years ago
apt install -y libxml2 libxml2-dev libbz2-dev libmcrypt-dev libpspell-dev librecode-dev
3 years ago
apt install -y libgmp-dev libgmp3-dev libreadline-dev libxpm-dev
3 years ago
apt install -y dia pkg-config
apt install -y zlib1g-dev
3 years ago
apt install -y libjpeg-dev libpng-dev
3 years ago
apt install -y libfreetype6
3 years ago
apt install -y libjpeg62-turbo-dev
3 years ago
apt install -y libfreetype6-dev
3 years ago
apt install -y libevent-dev libncurses5-dev libldap2-dev
3 years ago
apt install -y libzip-dev
3 years ago
apt install -y libicu-dev
3 years ago
3 years ago
apt install -y build-essential
3 years ago
3 years ago
apt install -y libcurl4-openssl-dev
3 years ago
apt install -y curl libcurl4-gnutls-dev
#https://blog.csdn.net/qq_36228377/article/details/123154344
3 years ago
# ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
3 years ago
if [ ! -d /usr/include/curl ];then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
fi
3 years ago
3 years ago
apt install -y graphviz bison re2c flex
3 years ago
apt install -y libsqlite3-dev
3 years ago
apt install -y libonig-dev
3 years ago
3 years ago
apt install -y perl g++ libtool
3 years ago
apt install -y libxslt1-dev
3 years ago
3 years ago
apt install -y libmariadb-dev
3 years ago
#apt install -y libmysqlclient-dev
3 years ago
apt install -y libmariadb-dev-compat
#apt install -y libmariadbclient-dev
5 years ago
else
3 years ago
3 years ago
yum install -y openldap openldap-devel libtirpc libtirpc-devel rpcgen
3 years ago
yum install -y bison re2c cmake
3 years ago
yum install -y libmemcached libmemcached-devel
yum install -y curl curl-devel
3 years ago
yum install -y zlib zlib-devel
3 years ago
yum install -y libzip libzip-devel
3 years ago
yum install -y pcre pcre-devel
3 years ago
yum install -y icu libicu-devel autoconf
3 years ago
yum install -y freetype freetype-devel
yum install -y openssl openssl-devel
yum install -y graphviz libxml2 libxml2-devel
yum install -y sqlite-devel
3 years ago
yum install -y mysql-devel
3 years ago
yum install -y oniguruma oniguruma-devel
yum install -y ImageMagick ImageMagick-devel
3 years ago
3 years ago
if [ "$OSNAME" == "fedora" ]; then
dnf install libxml2 libxml2-devel -y
3 years ago
fi
5 years ago
fi
3 years ago
#面板需要的库
if [ ! -f /usr/local/bin/pip3 ];then
python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple
fi
pip install --upgrade pip
pip3 install --upgrade setuptools
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt
pip3 install gevent-websocket==0.10.1
pip3 install requests==2.20.0
pip3 install flask-caching==1.10.1
pip3 install flask-session==0.3.2
pip3 install pymongo
pip3 install psutil
pip3 install flask-socketio==5.2.0
pip3 install mysqlclient
3 years ago
# if [ "${OSNAME}" == "ubuntu" ] && [ "${VERSION_ID}" == "22.04" ];then
# pip3 install -U --force-reinstall --no-binary :all: gevent
# fi
3 years ago
if [ ! -f /www/server/mdserver-web/bin/activate ];then
cd /www/server/mdserver-web && python3 -m venv .
3 years ago
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
else
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
fi
pip install --upgrade pip
pip3 install --upgrade setuptools
pip3 install -r /www/server/mdserver-web/requirements.txt
pip3 install gevent-websocket==0.10.1
pip3 install requests==2.20.0
pip3 install flask-caching==1.10.1
pip3 install flask-session==0.3.2
pip3 install pymongo
pip3 install psutil
pip3 install flask-socketio==5.2.0
pip3 install mysqlclient
3 years ago
# if [ "${OSNAME}" == "ubuntu" ] && [ "${VERSION_ID}" == "22.04" ];then
# pip3 install -U --force-reinstall --no-binary :all: gevent
# fi
3 years ago
##### common start #####
3 years ago
# Install_Libiconv
3 years ago
# Install_Libmemcached
# Install_Curl
# Install_Zlib
# Install_Freetype
# Install_Freetype_New
3 years ago
# Install_OpenSSL
# Install_Libzip
3 years ago
3 years ago
##### common end #####