74 lines
2.0 KiB
Bash
74 lines
2.0 KiB
Bash
#!/bin/bash
|
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
|
|
|
|
source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.acepanel.net/public.sh)
|
|
if [ $? -ne 0 ]; then
|
|
echo "Download public.sh failed, please check the network or try again later."
|
|
exit 1
|
|
fi
|
|
|
|
action=${1}
|
|
version=${2}
|
|
php_path="${setup_path}/server/php/${version}"
|
|
xhprof_version="2.3.10"
|
|
|
|
Install() {
|
|
# 检查是否已经安装
|
|
is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=xhprof')
|
|
if [ "${is_install}" != "" ]; then
|
|
error "PHP-${version} xhprof already installed"
|
|
fi
|
|
|
|
cd ${php_path}/src/ext
|
|
rm -rf xhprof
|
|
rm -rf xhprof-${xhprof_version}.tgz
|
|
dl "${php_path}/src/ext" "/php_exts/xhprof-${xhprof_version}.tgz"
|
|
|
|
tar -xzf xhprof-${xhprof_version}.tgz
|
|
mv xhprof-${xhprof_version} xhprof
|
|
rm -f package.xml
|
|
rm -f xhprof-${xhprof_version}.tgz
|
|
cd xhprof/extension
|
|
${php_path}/bin/phpize
|
|
./configure --with-php-config=${php_path}/bin/php-config
|
|
make
|
|
if [ "$?" != "0" ]; then
|
|
rm -rf ${php_path}/src/ext/xhprof
|
|
error "PHP-${version} xhprof compilation failed"
|
|
fi
|
|
make install
|
|
if [ "$?" != "0" ]; then
|
|
rm -rf ${php_path}/src/ext/xhprof
|
|
error "PHP-${version} xhprof installation failed"
|
|
fi
|
|
|
|
sed -i '/;panel/a\extension=xhprof' ${php_path}/etc/php.ini
|
|
|
|
# 重载PHP
|
|
systemctl reload php-fpm-${version}.service
|
|
echo -e $HR
|
|
echo "PHP-${version} xhprof installation successful"
|
|
}
|
|
|
|
Uninstall() {
|
|
# 检查是否已经安装
|
|
is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=xhprof$')
|
|
if [ "${is_install}" == "" ]; then
|
|
error "PHP-${version} xhprof not installed"
|
|
fi
|
|
|
|
sed -i '/extension=xhprof/d' ${php_path}/etc/php.ini
|
|
|
|
# 重载PHP
|
|
systemctl reload php-fpm-${version}.service
|
|
echo -e $HR
|
|
echo "PHP-${version} xhprof uninstall successful"
|
|
}
|
|
|
|
if [ "$action" == 'install' ]; then
|
|
Install
|
|
fi
|
|
if [ "$action" == 'uninstall' ]; then
|
|
Uninstall
|
|
fi
|