Files
download/php_exts/swoole.sh
耗子 758e1c8799
All checks were successful
Generate Checksums / checksums (push) Successful in 46s
feat: 清理提交
2026-01-31 07:03:45 +08:00

80 lines
2.1 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}"
swoole_version="6.1.6"
if [ ${version} -le "81" ]; then
swoole_version="5.1.8"
fi
if [ ${version} -le "74" ]; then
swoole_version="4.8.13"
fi
Install() {
# 检查是否已经安装
is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=swoole')
if [ "${is_install}" != "" ]; then
error "PHP-${version} swoole already installed"
fi
cd ${php_path}/src/ext
rm -rf swoole
rm -rf swoole-src-${swoole_version}.zip
dl "${php_path}/src/ext" "/php_exts/swoole-src-${swoole_version}.zip"
unzip swoole-src-${swoole_version}.zip
mv swoole-src-${swoole_version} swoole
rm -f swoole-src-${swoole_version}.zip
cd swoole
${php_path}/bin/phpize
./configure --with-php-config=${php_path}/bin/php-config --enable-openssl --enable-swoole-curl
make
if [ "$?" != "0" ]; then
rm -rf ${php_path}/src/ext/swoole
error "PHP-${version} swoole compilation failed"
fi
make install
if [ "$?" != "0" ]; then
rm -rf ${php_path}/src/ext/swoole
error "PHP-${version} swoole installation failed"
fi
sed -i '/;panel/a\extension=swoole' ${php_path}/etc/php.ini
# 重载PHP
systemctl reload php-fpm-${version}.service
echo -e $HR
echo "PHP-${version} swoole installation successful"
}
Uninstall() {
# 检查是否已经安装
is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=swoole$')
if [ "${is_install}" == "" ]; then
error "PHP-${version} swoole not installed"
fi
sed -i '/extension=swoole/d' ${php_path}/etc/php.ini
# 重载PHP
systemctl reload php-fpm-${version}.service
echo -e $HR
echo "PHP-${version} swoole uninstall successful"
}
if [ "$action" == 'install' ]; then
Install
fi
if [ "$action" == 'uninstall' ]; then
Uninstall
fi