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}"
|
|
protobuf_version="4.33.3"
|
|
|
|
Install() {
|
|
# 检查是否已经安装
|
|
is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=protobuf')
|
|
if [ "${is_install}" != "" ]; then
|
|
error "PHP-${version} protobuf already installed"
|
|
fi
|
|
|
|
cd ${php_path}/src/ext
|
|
rm -rf protobuf
|
|
rm -rf protobuf-${protobuf_version}.tgz
|
|
dl "${php_path}/src/ext" "/php_exts/protobuf-${protobuf_version}.tgz"
|
|
|
|
tar -xzf protobuf-${protobuf_version}.tgz
|
|
mv protobuf-${protobuf_version} protobuf
|
|
rm -f package.xml
|
|
rm -f protobuf-${protobuf_version}.tgz
|
|
cd protobuf
|
|
${php_path}/bin/phpize
|
|
./configure --with-php-config=${php_path}/bin/php-config
|
|
make
|
|
if [ "$?" != "0" ]; then
|
|
rm -rf ${php_path}/src/ext/protobuf
|
|
error "PHP-${version} protobuf compilation failed"
|
|
fi
|
|
make install
|
|
if [ "$?" != "0" ]; then
|
|
rm -rf ${php_path}/src/ext/protobuf
|
|
error "PHP-${version} protobuf installation failed"
|
|
fi
|
|
|
|
sed -i '/;panel/a\extension=protobuf' ${php_path}/etc/php.ini
|
|
|
|
# 重载PHP
|
|
systemctl reload php-fpm-${version}.service
|
|
echo -e $HR
|
|
echo "PHP-${version} protobuf installation successful"
|
|
}
|
|
|
|
Uninstall() {
|
|
# 检查是否已经安装
|
|
is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=protobuf$')
|
|
if [ "${is_install}" == "" ]; then
|
|
error "PHP-${version} protobuf not installed"
|
|
fi
|
|
|
|
sed -i '/extension=protobuf/d' ${php_path}/etc/php.ini
|
|
|
|
# 重载PHP
|
|
systemctl reload php-fpm-${version}.service
|
|
echo -e $HR
|
|
echo "PHP-${version} protobuf uninstall successful"
|
|
}
|
|
|
|
if [ "$action" == 'install' ]; then
|
|
Install
|
|
fi
|
|
if [ "$action" == 'uninstall' ]; then
|
|
Uninstall
|
|
fi
|