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

71 lines
1.6 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}
postgresql_path="${setup_path}/server/postgresql"
j=$(calculate_j)
# 预检查
systemctl is-active --quiet postgresql
if [ "$?" != "0" ]; then
error "Application is not running properly"
fi
# 准备目录
cd ${postgresql_path}
rm -rf src
# 下载源码
dl "${postgresql_path}" "/postgresql/postgresql-${version}.7z"
7z x postgresql-${version}.7z
rm -f postgresql-${version}.7z
mv postgresql-${version} src
# 编译
cd src
meson setup build --buildtype=release --prefix=${postgresql_path} -Dnls=enabled -Dlz4=enabled -Dzstd=enabled -Dssl=openssl -Dsystemd=enabled -Dlibcurl=enabled -Dliburing=enabled -Dlibxml=enabled -Dlibxslt=enabled
if [ "$?" != "0" ]; then
error "Compilation initialization failed"
fi
cd build
ninja
if [ "$?" != "0" ]; then
error "Compilation failed"
fi
# 停止已有服务
systemctl stop postgresql
ninja install
if [ "$?" != "0" ]; then
error "Installation failed"
fi
cd ${postgresql_path}
rm -rf ${postgresql_path}/src
# 配置
chown -R postgres:postgres ${postgresql_path}
chmod -R 700 ${postgresql_path}
# 启动服务
systemctl daemon-reload
systemctl start postgresql
if [ "$?" != "0" ]; then
error "Failed to start"
fi
acepanel app write postgresql ${channel} ${version}
echo -e $HR
echo "Upgrade successful"
echo -e $HR