Files
download/panel/pureftpd/update.sh
耗子 a65d23f05b
Some checks failed
Generate Checksums / checksums (push) Has been cancelled
feat: 移除协议
2025-08-22 06:19:40 +08:00

80 lines
2.6 KiB (Stored with Git LFS)
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.cdn.haozi.net/panel/public.sh)
if [ $? -ne 0 ]; then
echo "下载 public.sh 失败,请检查网络或稍后重试。"
echo "Download public.sh failed, please check the network or try again later."
exit 1
fi
channel=${1}
version=${2}
pureftpd_path="${setupPath}/server/pure-ftpd"
j=$(calculate_j)
# 预检查
systemctl is-active --quiet pure-ftpd
if [ "$?" != "0" ]; then
error "应用运行状态不正常"
fi
# 准备安装目录
cp ${pureftpd_path}/etc/pureftpd.passwd /tmp/pureftpd.passwd
cp ${pureftpd_path}/etc/pureftpd.pdb /tmp/pureftpd.pdb
cp ${pureftpd_path}/etc/pureftpd.conf /tmp/pureftpd.conf
systemctl stop pure-ftpd.service
cd ${pureftpd_path}
rm -rf src
wget --retry-connrefused --retry-on-host-error --retry-on-http-error=429,500,502,503,504 -t 10 -T 120 -O ${pureftpd_path}/pure-ftpd-${version}.tar.gz ${download_url}/pureftpd/pure-ftpd-${version}.tar.gz
wget --retry-connrefused --retry-on-host-error --retry-on-http-error=429,500,502,503,504 -t 10 -T 120 -O ${pureftpd_path}/pure-ftpd-${version}.tar.gz.sha256 ${download_url}/pureftpd/pure-ftpd-${version}.tar.gz.sha256
if ! sha256sum --status -c pure-ftpd-${version}.tar.gz.sha256; then
rm -f pure-ftpd-${version}.tar.gz
rm -f pure-ftpd-${version}.tar.gz.sha256
error "Pure-Ftpd 校验失败"
fi
tar -xvf pure-ftpd-${version}.tar.gz
rm -f pure-ftpd-${version}.tar.gz
rm -f pure-ftpd-${version}.tar.gz.sha256
mv pure-ftpd-${version} src
cd src
./configure --prefix=${pureftpd_path} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=simplified-chinese --with-rfc2640 --with-ftpwho --with-tls
if [ "$?" != "0" ]; then
error "Pure-Ftpd 编译初始化失败"
fi
make "-j${j}"
if [ "$?" != "0" ]; then
error "Pure-Ftpd 编译失败"
fi
# 停止已有服务
systemctl stop pure-ftpd
make install
if [ ! -f "${pureftpd_path}/bin/pure-pw" ]; then
error "Pure-Ftpd 安装失败"
fi
# 还原配置
cp /tmp/pureftpd.passwd ${pureftpd_path}/etc/pureftpd.passwd
cp /tmp/pureftpd.pdb ${pureftpd_path}/etc/pureftpd.pdb
cp /tmp/pureftpd.conf ${pureftpd_path}/etc/pureftpd.conf
systemctl daemon-reload
systemctl start pure-ftpd
if [ "$?" != "0" ]; then
error "启动失败"
fi
panel-cli app write pureftpd ${channel} ${version}
echo -e $HR
echo "升级完成"
echo -e $HR