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/php-apt/versions/common/yaf.sh

103 lines
2.3 KiB

3 years ago
#!/bin/bash
3 years ago
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
3 years ago
3 years ago
curPath=`pwd`
rootPath=$(dirname "$curPath")
3 years ago
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
3 years ago
actionType=$1
3 years ago
version=$2
3 years ago
sysName=`uname`
LIBNAME=yaf
LIBV=3.3.5
3 years ago
if [ `echo "$version < 7.0"|bc` -eq 1 ];then
LIBV=2.3.5
fi
3 years ago
3 years ago
extVer=`bash $curPath/lib.sh $version`
3 years ago
extFile=/usr/lib/php/${extVer}/${LIBNAME}.so
3 years ago
3 years ago
3 years ago
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
Install_lib()
{
3 years ago
#cat /etc/php/${version}/fpm/conf.d/* | grep -v '^;' |tr -s '\n'
isInstall=`cat /etc/php/${version}/fpm/conf.d/* | grep -v '^;' |tr -s '\n' |grep "${LIBNAME}.so"`
3 years ago
if [ "${isInstall}" != "" ];then
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
return
fi
if [ ! -f "$extFile" ];then
php_lib=$sourcePath/php_lib
mkdir -p $php_lib
if [ ! -d $php_lib/${LIBNAME}-${LIBV} ];then
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
fi
cd $php_lib/${LIBNAME}-${LIBV}
3 years ago
/usr/bin/phpize${version}
./configure --with-php-config=/usr/bin/php-config${version}
3 years ago
make && make install && make clean
fi
3 years ago
echo "$extFile checking ..."
3 years ago
if [ ! -f "$extFile" ];then
echo "ERROR!"
return;
fi
3 years ago
3 years ago
3 years ago
echo "" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini
echo "[${LIBNAME}]" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini
echo "extension=${LIBNAME}.so" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini
echo "${LIBNAME}.use_namespace=1" >> /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini
3 years ago
3 years ago
systemctl restart php${version}-fpm
3 years ago
echo '==========================================================='
echo 'successful!'
}
Uninstall_lib()
{
3 years ago
if [ ! -f "/usr/bin/php-config${version}" ];then
3 years ago
echo "php-$version 未安装,请选择其它版本!"
return
fi
3 years ago
if [ -f /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini ];then
rm -rf /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini
3 years ago
rm -rf $extFile
fi
3 years ago
systemctl restart php${version}-fpm
3 years ago
echo '==============================================='
echo 'successful!'
}
3 years ago
3 years ago
if [ "$actionType" == 'install' ];then
Install_lib
elif [ "$actionType" == 'uninstall' ];then
Uninstall_lib
fi