Refactor Postgresus update script and update logo URL

Simplifies the update process in ct/postgresus.sh by using a helper function for fetching and deploying releases, streamlining frontend and backend build steps, and improving status messages. Updates the logo URL in frontend/public/json/postgresus.json to use a CDN-hosted image.
This commit is contained in:
CanbiZ 2025-12-11 13:39:08 +01:00
parent 8a338f01b7
commit cf73665ed1
2 changed files with 21 additions and 40 deletions

View File

@ -30,65 +30,46 @@ function update_script() {
fi fi
if check_for_gh_release "RostislavDugin" "postgresus"; then if check_for_gh_release "RostislavDugin" "postgresus"; then
msg_info "Stopping ${APP}" msg_info "Stopping Postgresus"
systemctl stop postgresus $STD systemctl stop postgresus
msg_ok "Stopped ${APP}" msg_ok "Stopped Postgresus"
RELEASE=$(curl -fsSL https://api.github.com/repos/RostislavDugin/postgresus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
msg_info "Backing up Configuration" msg_info "Backing up Configuration"
cp /opt/postgresus/.env /tmp/postgresus.env.bak cp /opt/postgresus/.env /tmp/postgresus.env.bak
msg_ok "Backed up Configuration" msg_ok "Backed up Configuration"
msg_info "Building new version v${RELEASE}" fetch_and_deploy_gh_release "postgresus" "RostislavDugin/postgresus" "tarball" "v${RELEASE}" "/opt/postgresus"
cd /tmp
curl -fsSL "https://github.com/RostislavDugin/postgresus/archive/refs/tags/v${RELEASE}.tar.gz" -o postgresus.tar.gz
tar -xzf postgresus.tar.gz
cd "postgresus-${RELEASE}"
# Build frontend msg_info "Updating Postgresus"
cd frontend cd /opt/postgresus/frontend
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
cd .. cd /opt/postgresus/backend
# Build backend
cd backend
$STD go mod download $STD go mod download
CGO_ENABLED=0 go build -o /opt/postgresus/postgresus.new ./cmd/main.go $STD go build -o ../postgresus ./cmd/main.go
cd .. cd /opt/postgresus/
cp -r frontend/dist ui
# Update files cp -r backend/migrations .
mv /opt/postgresus/postgresus /opt/postgresus/postgresus.backup msg_ok "Updated Postgresus"
mv /opt/postgresus/postgresus.new /opt/postgresus/postgresus
chmod +x /opt/postgresus/postgresus
cp -r frontend/dist /opt/postgresus/ui
cp -r backend/migrations /opt/postgresus/
cd /tmp && rm -rf "postgresus-${RELEASE}" postgresus.tar.gz
msg_ok "Built new version v${RELEASE}"
msg_info "Restoring Configuration" msg_info "Restoring Configuration"
cp /tmp/postgresus.env.bak /opt/postgresus/.env cp /tmp/postgresus.env.bak /opt/postgresus/.env
rm -f /tmp/postgresus.env.bak rm -f /tmp/postgresus.env.bak
chown -R postgresus:postgresus /opt/postgresus
msg_ok "Restored Configuration" msg_ok "Restored Configuration"
msg_info "Starting ${APP}" msg_info "Starting Postgresus"
systemctl start postgresus $STD systemctl start postgresus
msg_ok "Started ${APP}" msg_ok "Started Postgresus"
msg_ok "Updated successfully!"
msg_ok "Updated Successfully to v${RELEASE}"
else
msg_ok "No update available"
fi fi
exit exit
}start }
start
build_container build_container
description description
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4005${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

View File

@ -12,7 +12,7 @@
"interface_port": 80, "interface_port": 80,
"documentation": "https://github.com/RostislavDugin/postgresus", "documentation": "https://github.com/RostislavDugin/postgresus",
"website": "https://github.com/RostislavDugin/postgresus", "website": "https://github.com/RostislavDugin/postgresus",
"logo": "https://raw.githubusercontent.com/RostislavDugin/postgresus/main/frontend/public/logo.svg", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/postgresus.webp",
"config_path": "/opt/postgresus/.env", "config_path": "/opt/postgresus/.env",
"description": "Free, open source and self-hosted solution for automated PostgreSQL backups. With multiple storage options, notifications, scheduling, and a beautiful web interface for managing database backups across multiple PostgreSQL instances.", "description": "Free, open source and self-hosted solution for automated PostgreSQL backups. With multiple storage options, notifications, scheduling, and a beautiful web interface for managing database backups across multiple PostgreSQL instances.",
"install_methods": [ "install_methods": [