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

96 lines
2.4 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-11-30 03:55:45 -05:00
LIBNAME=yaf
2019-11-29 12:24:28 -05:00
LIBV=2.3.5
2019-01-14 03:49:50 -05:00
2020-07-11 11:47:58 -04:00
sysName=`uname`
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
2019-01-14 03:49:50 -05:00
Install_lib()
2019-01-14 00:13:24 -05:00
{
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-01-14 02:28:27 -05:00
2019-11-30 03:55:45 -05:00
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.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
2019-01-14 02:28:27 -05:00
2019-11-29 04:21:38 -05:00
php_lib=$sourcePath/php_lib
2019-01-14 02:28:27 -05:00
mkdir -p $php_lib
2020-07-11 11:50:34 -04:00
if [ ! -d $php_lib/${LIBNAME}-${LIBV} ];then
2019-11-29 12:24:28 -05:00
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-01-14 00:13:24 -05:00
2019-01-14 02:28:27 -05:00
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
2019-11-29 04:21:38 -05:00
make && make install && make clean
2019-11-29 05:29:23 -05:00
2019-01-14 00:13:24 -05:00
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
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-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