From 9809a6e880f63d9569cba6b58ed4379575b94d5e Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Mon, 14 Jan 2019 13:13:24 +0800 Subject: [PATCH] update --- class/core/plugins_api.py | 2 +- class/core/public.py | 2 +- plugins/php/index.py | 18 +++-- plugins/php/versions/56/yaf.sh | 122 +++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 plugins/php/versions/56/yaf.sh diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index a6ac547b7..59d101bfa 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -48,7 +48,7 @@ class plugins_api: def listApi(self): sType = request.args.get('type', '0') sPage = request.args.get('p', '1') - print sPage + # print sPage data = self.getPluginList(sType, int(sPage)) return public.getJson(data) diff --git a/class/core/public.py b/class/core/public.py index 8854da29c..eedb29ec3 100755 --- a/class/core/public.py +++ b/class/core/public.py @@ -310,7 +310,7 @@ def httpGet(url, timeout=30): response = urllib2.urlopen(url, timeout=timeout) return response.read() except Exception, ex: - # WriteLog('网络诊断',str(ex) + '['+url+']'); + # writeLog('网络诊断', str(ex) + '[' + url + ']') return str(ex) diff --git a/plugins/php/index.py b/plugins/php/index.py index ae0e7074e..45008b784 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -495,11 +495,12 @@ def checkPhpinfoFile(version): def getPhpinfo(version): checkPhpinfoFile(version) sPath = public.getRootDir() + '/phpinfo/' + version - public.execShell("rm -rf " + public.getRootDir() + '/phpinfo') + # public.execShell("rm -rf " + public.getRootDir() + '/phpinfo') public.execShell("mkdir -p " + sPath) public.writeFile(sPath + '/phpinfo.php', '') - phpinfo = public.httpGet('http://127.0.0.1/' + version + '/phpinfo.php') - os.system("rm -rf " + public.getRootDir() + '/phpinfo') + # print 'http://127.0.0.1/' + version + '/phpinfo.php' + phpinfo = public.httpGet('http://127.0.0.1/' + version + '/phpinfo.php', 3) + # os.system("rm -rf " + public.getRootDir() + '/phpinfo') return phpinfo @@ -547,11 +548,16 @@ def installLib(version): name + '.sh' + " " + stype + " " + version rettime = time.strftime('%Y-%m-%d %H:%M:%S') - public.M('tasks').add('id,name,type,status,addtime,execstr', (None, - '安装[' + name + '-' + version + ']', 'execshell', '0', rettime, execstr)) + insert_info = (None, '安装[' + name + '-' + version + ']', + 'execshell', '0', rettime, execstr) + public.M('tasks').add('id,name,type,status,addtime,execstr', insert_info) # print execstr return public.returnJson(True, '已将下载任务添加到队列!') + +def uninstallLib(version): + return 'ok' + if __name__ == "__main__": if len(sys.argv) < 3: @@ -603,5 +609,7 @@ if __name__ == "__main__": print getLibConf(version) elif func == 'install_lib': print installLib(version) + elif func == 'uninstall_lib': + print uninstallLib(version) else: print "fail" diff --git a/plugins/php/versions/56/yaf.sh b/plugins/php/versions/56/yaf.sh new file mode 100644 index 000000000..67add87aa --- /dev/null +++ b/plugins/php/versions/56/yaf.sh @@ -0,0 +1,122 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +Install_yaf() +{ + case "${version}" in + '54') + extFile='/www/server/php/54/lib/php/extensions/no-debug-non-zts-20100525/yaf.so' + ;; + '55') + extFile='/www/server/php/55/lib/php/extensions/no-debug-non-zts-20121212/yaf.so' + ;; + '56') + extFile='/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/yaf.so' + ;; + '70') + extFile='/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/yaf.so' + ;; + '71') + extFile='/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/yaf.so' + ;; + '71') + extFile='/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/yaf.so' + ;; + '72') + extFile='/www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/yaf.so' + ;; + esac + + isInstall=`cat /www/server/php/$version/etc/php.ini|grep 'yaf.so'` + if [ "${isInstall}" != "" ];then + echo "php-$vphp 已安装yaf,请选择其它版本!" + return + fi + + + if [ ! -f "$extFile" ];then + public_file=/www/server/panel/install/public.sh + if [ ! -f $public_file ];then + wget -O $public_file http://download.bt.cn/install/public.sh -T 5; + fi + . $public_file + + download_Url=$NODE_URL + + wafV='2.3.5'; + if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ];then + wafV='3.0.7'; + fi + wget -O yaf-$wafV.tgz $download_Url/src/yaf-$wafV.tgz + tar xvf yaf-$wafV.tgz + cd yaf-$wafV + + /www/server/php/$version/bin/phpize + ./configure --with-php-config=/www/server/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 + echo "extension=$extFile" >> /www/server/php/$version/etc/php.ini + + service php-fpm-$version reload + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_yaf() +{ + if [ ! -f "/www/server/php/$version/bin/php-config" ];then + echo "php-$vphp 未安装,请选择其它版本!" + return + fi + + case "${version}" in + '54') + extFile='/www/server/php/54/lib/php/extensions/no-debug-non-zts-20100525/yaf.so' + ;; + '55') + extFile='/www/server/php/55/lib/php/extensions/no-debug-non-zts-20121212/yaf.so' + ;; + '56') + extFile='/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/yaf.so' + ;; + '70') + extFile='/www/server/php/70/lib/php/extensions/no-debug-non-zts-20151012/yaf.so' + ;; + '71') + extFile='/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/yaf.so' + ;; + '72') + extFile='/www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718/yaf.so' + esac + if [ ! -f "$extFile" ];then + echo "php-$vphp 未安装yaf,请选择其它版本!" + return + fi + + sed -i '/yaf.so/d' /www/server/php/$version/etc/php.ini + + rm -f $extFile + /etc/init.d/php-fpm-$version reload + echo '===============================================' + echo 'successful!' +} + + +actionType=$1 +version=$2 +vphp=${version:0:1}.${version:1:1} +if [ "$actionType" == 'install' ];then + Install_yaf +elif [ "$actionType" == 'uninstall' ];then + Uninstall_yaf +fi \ No newline at end of file