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

100 lines
2.5 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
2019-03-08 05:52:37 -05:00
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${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
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-03-07 22:39:22 -05:00
2019-03-07 06:05:12 -05:00
php_lib=$sourcePath/php_${version}_lib
2019-03-07 22:39:22 -05:00
2019-03-07 06:05:12 -05:00
mkdir -p $php_lib
2019-03-07 22:39:22 -05:00
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
2019-03-07 06:05:12 -05:00
cd $php_lib
2019-03-07 22:39:22 -05:00
tar xvf ${LIBNAME}-${LIBV}.tgz
cd ${LIBNAME}-${LIBV}
2019-03-07 06:05:12 -05:00
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
make && make install
cd ..
rm -rf yaf-*
rm -f package.xml
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
2019-03-07 22:39:22 -05: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