mdserver-web/plugins/php-apt/versions/common/yaf.sh

101 lines
2.3 KiB
Bash
Raw Permalink Normal View History

2022-07-08 09:33:53 -04:00
#!/bin/bash
2022-07-09 06:03:38 -04:00
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
2022-07-08 09:33:53 -04:00
2022-07-09 06:03:38 -04:00
curPath=`pwd`
rootPath=$(dirname "$curPath")
2022-07-09 23:34:36 -04:00
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
2022-07-09 06:03:38 -04:00
actionType=$1
2022-07-08 09:33:53 -04:00
version=$2
2022-07-09 06:03:38 -04:00
sysName=`uname`
LIBNAME=yaf
2024-07-23 09:42:16 -04:00
LIBV=3.3.6
2022-07-09 06:03:38 -04:00
2022-07-09 13:13:34 -04:00
if [ `echo "$version < 7.0"|bc` -eq 1 ];then
LIBV=2.3.5
fi
2022-07-09 23:07:12 -04:00
extVer=`bash $curPath/lib.sh $version`
2022-07-09 13:13:34 -04:00
extFile=/usr/lib/php/${extVer}/${LIBNAME}.so
2022-07-09 06:03:38 -04:00
2022-07-09 23:07:12 -04:00
2022-07-09 06:03:38 -04:00
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
Install_lib()
{
2022-07-09 13:13:34 -04:00
#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"`
2022-07-09 06:03:38 -04:00
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}
2022-07-09 12:21:09 -04:00
/usr/bin/phpize${version}
./configure --with-php-config=/usr/bin/php-config${version}
2022-07-09 06:03:38 -04:00
make && make install && make clean
fi
2022-07-09 23:07:12 -04:00
echo "$extFile checking ..."
2022-07-09 06:03:38 -04:00
if [ ! -f "$extFile" ];then
echo "ERROR!"
return;
fi
2022-07-09 13:13:34 -04:00
2022-07-09 06:03:38 -04:00
2022-07-09 13:13:34 -04:00
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
2022-07-09 06:03:38 -04:00
2022-07-09 13:13:34 -04:00
systemctl restart php${version}-fpm
2022-07-09 06:03:38 -04:00
echo '==========================================================='
echo 'successful!'
}
Uninstall_lib()
{
2022-07-09 13:13:34 -04:00
if [ ! -f "/usr/bin/php-config${version}" ];then
2022-07-09 06:03:38 -04:00
echo "php-$version 未安装,请选择其它版本!"
return
fi
2022-07-09 23:39:40 -04:00
if [ -f /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini ];then
rm -rf /etc/php/${version}/fpm/conf.d/${LIBNAME}.ini
2022-07-09 23:34:36 -04:00
rm -rf $extFile
fi
2022-07-09 13:13:34 -04:00
systemctl restart php${version}-fpm
2022-07-09 06:03:38 -04:00
echo '==============================================='
echo 'successful!'
}
2022-07-08 09:33:53 -04:00
2022-07-09 06:03:38 -04:00
if [ "$actionType" == 'install' ];then
Install_lib
elif [ "$actionType" == 'uninstall' ];then
Uninstall_lib
fi