mdserver-web/plugins/php/versions/53/yaf.sh

105 lines
2.6 KiB
Bash
Raw Normal View History

2019-03-07 06:05:12 -05:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
2019-03-07 22:39:22 -05:00
LIBNAME=yaf
LIBV='2.3.5'
2019-03-07 06:05:12 -05:00
actionType=$1
version=$2
2021-12-03 03:54:44 -05:00
NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts`
extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so
2019-03-07 06:05:12 -05:00
2019-03-07 22:39:22 -05:00
if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ] || [ "$version" = '73' ];then
LIBV='3.0.7';
fi
2020-07-11 11:47:58 -04:00
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
2019-03-07 06:05:12 -05:00
Install_lib()
{
2019-03-07 22:39:22 -05:00
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
2019-03-07 06:05:12 -05:00
if [ "${isInstall}" != "" ];then
2019-03-13 05:59:07 -04:00
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
2019-03-07 06:05:12 -05:00
return
fi
if [ ! -f "$extFile" ];then
2019-11-29 03:36:09 -05:00
php_lib=$sourcePath/php_lib
2019-03-07 06:05:12 -05:00
mkdir -p $php_lib
2019-11-30 03:55:45 -05:00
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}
2019-03-07 22:39:22 -05:00
2019-03-07 06:05:12 -05:00
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
2019-11-29 03:36:09 -05:00
make && make install && make clean
2019-11-29 05:29:23 -05:00
2019-03-07 06:05:12 -05:00
fi
if [ ! -f "$extFile" ];then
echo "ERROR!"
return;
fi
2019-03-08 04:11:20 -05:00
echo "" >> $serverPath/php/$version/etc/php.ini
2019-03-08 05:52:37 -05:00
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
2019-03-08 04:11:20 -05:00
echo "yaf.use_namespace=1" >> $serverPath/php/$version/etc/php.ini
2019-03-07 06:05:12 -05:00
$serverPath/php/init.d/php$version reload
echo '==========================================================='
echo 'successful!'
}
Uninstall_lib()
{
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
echo "php$version 未安装,请选择其它版本!"
return
fi
if [ ! -f "$extFile" ];then
2019-03-13 05:59:07 -04:00
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
echo "php-$version not install ${LIBNAME}, Plese select other version!"
2019-03-07 06:05:12 -05:00
return
fi
echo $serverPath/php/$version/etc/php.ini
2020-07-11 11:47:58 -04:00
sed -i $BAK "/yaf.so/d" $serverPath/php/$version/etc/php.ini
sed -i $BAK "/yaf.use_namespace/d" $serverPath/php/$version/etc/php.ini
sed -i $BAK "/\[yaf\]/d" $serverPath/php/$version/etc/php.ini
2019-03-07 06:05:12 -05:00
rm -f $extFile
$serverPath/php/init.d/php$version reload
echo '==============================================='
echo 'successful!'
}
if [ "$actionType" == 'install' ];then
Install_lib
elif [ "$actionType" == 'uninstall' ];then
Uninstall_lib
fi