72 lines
2.0 KiB
Bash
72 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
|
|
|
|
channel=${1}
|
|
version=${2}
|
|
pureftpd_path="${setup_path}/server/pure-ftpd"
|
|
j=$(calculate_j)
|
|
|
|
# 预检查
|
|
systemctl is-active --quiet pure-ftpd
|
|
if [ "$?" != "0" ]; then
|
|
error "Application is not running properly"
|
|
fi
|
|
|
|
# 准备安装目录
|
|
\cp -f ${pureftpd_path}/etc/pureftpd.passwd /tmp/pureftpd.passwd
|
|
\cp -f ${pureftpd_path}/etc/pureftpd.pdb /tmp/pureftpd.pdb
|
|
\cp -f ${pureftpd_path}/etc/pureftpd.conf /tmp/pureftpd.conf
|
|
systemctl stop pure-ftpd.service
|
|
|
|
cd ${pureftpd_path}
|
|
rm -rf src
|
|
|
|
dl "${pureftpd_path}" "/pureftpd/pure-ftpd-${version}.tar.gz"
|
|
|
|
tar -xvf pure-ftpd-${version}.tar.gz
|
|
rm -f pure-ftpd-${version}.tar.gz
|
|
mv pure-ftpd-${version} src
|
|
cd src
|
|
chmod +x configure
|
|
|
|
./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 "Compilation initialization failed"
|
|
fi
|
|
|
|
make "-j${j}"
|
|
if [ "$?" != "0" ]; then
|
|
error "Compilation failed"
|
|
fi
|
|
|
|
# 停止已有服务
|
|
systemctl stop pure-ftpd
|
|
|
|
make install
|
|
if [ ! -f "${pureftpd_path}/bin/pure-pw" ]; then
|
|
error "Installation failed"
|
|
fi
|
|
|
|
# 还原配置
|
|
\cp -f /tmp/pureftpd.passwd ${pureftpd_path}/etc/pureftpd.passwd
|
|
\cp -f /tmp/pureftpd.pdb ${pureftpd_path}/etc/pureftpd.pdb
|
|
\cp -f /tmp/pureftpd.conf ${pureftpd_path}/etc/pureftpd.conf
|
|
|
|
systemctl daemon-reload
|
|
systemctl start pure-ftpd
|
|
if [ "$?" != "0" ]; then
|
|
error "Failed to start"
|
|
fi
|
|
|
|
acepanel app write pureftpd ${channel} ${version}
|
|
|
|
echo -e $HR
|
|
echo "Upgrade successful"
|
|
echo -e $HR
|