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

90 lines
2.2 KiB
Bash
Raw Normal View History

2019-01-14 00:13:24 -05:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
2019-01-14 02:28:27 -05:00
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
2019-01-14 03:49:50 -05:00
Install_lib()
2019-01-14 00:13:24 -05:00
{
2019-01-14 02:28:27 -05:00
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20131226/yaf.so
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep 'yaf.so'`
2019-01-14 00:13:24 -05:00
if [ "${isInstall}" != "" ];then
2019-01-14 02:28:27 -05:00
echo "php-$version 已安装yaf,请选择其它版本!"
2019-01-14 00:13:24 -05:00
return
fi
if [ ! -f "$extFile" ];then
wafV='2.3.5';
if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ];then
wafV='3.0.7';
fi
2019-01-14 02:28:27 -05:00
php_lib=$sourcePath/php_${version}_lib
mkdir -p $php_lib
wget -O $php_lib/yaf-$wafV.tgz http://pecl.php.net/get/yaf-$wafV.tgz
cd $php_lib
2019-01-14 00:13:24 -05:00
tar xvf yaf-$wafV.tgz
cd yaf-$wafV
2019-01-14 02:28:27 -05:00
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
2019-01-14 00:13:24 -05:00
make && make install
cd ..
rm -rf yaf-*
rm -f package.xml
fi
if [ ! -f "$extFile" ];then
echo "ERROR!"
return;
fi
2019-01-15 01:31:14 -05:00
2019-02-14 23:59:06 -05:00
echo -e "[yaf]\nextension=yaf.so\nyaf.use_namespace=1" >> $serverPath/php/$version/etc/php.ini
2019-01-14 00:13:24 -05:00
2019-01-14 02:28:27 -05:00
$serverPath/php/init.d/php$version reload
2019-01-14 00:13:24 -05:00
echo '==========================================================='
echo 'successful!'
}
2019-01-14 03:49:50 -05:00
Uninstall_lib()
2019-01-14 00:13:24 -05:00
{
2019-01-14 02:28:27 -05:00
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
echo "php$version 未安装,请选择其它版本!"
2019-01-14 00:13:24 -05:00
return
fi
2019-01-14 02:28:27 -05:00
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20131226/yaf.so
2019-01-14 00:13:24 -05:00
if [ ! -f "$extFile" ];then
2019-01-14 02:28:27 -05:00
echo "php$version 未安装yaf,请选择其它版本!"
2019-01-14 00:13:24 -05:00
return
fi
2019-01-14 02:28:27 -05:00
echo $serverPath/php/$version/etc/php.ini
sed -i '_bak' '/yaf.so/d' $serverPath/php/$version/etc/php.ini
2019-02-14 23:59:06 -05:00
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-01-14 00:13:24 -05:00
rm -f $extFile
2019-01-14 02:28:27 -05:00
$serverPath/php/init.d/php$version reload
2019-01-14 00:13:24 -05:00
echo '==============================================='
echo 'successful!'
}
actionType=$1
version=$2
if [ "$actionType" == 'install' ];then
2019-01-14 03:49:50 -05:00
Install_lib
2019-01-14 00:13:24 -05:00
elif [ "$actionType" == 'uninstall' ];then
2019-01-14 03:49:50 -05:00
Uninstall_lib
2019-01-14 00:13:24 -05:00
fi