Now use check_for_gh_release and fetch_and_deploy

removed ${APP} everywhere
Removed exit
Rephrase msg
This commit is contained in:
DragoQC 2025-11-27 11:56:17 -05:00
parent 845b909549
commit c719285e67

View File

@ -29,48 +29,37 @@ function update_script() {
exit exit
fi fi
LATEST=$(curl -fsSL https://api.github.com/repos/nickheyer/discopanel/releases/latest \ if check_for_gh_release "discopanel" "nickheyer/discopanel"; then
grep '"tag_name":' | cut -d'"' -f4) msg_info "Stopping Service"
systemctl stop discopanel
CURRENT=$(cat /opt/${APP}_version.txt 2>/dev/null || echo "none") msg_ok "Stopped Service"
if [[ "$LATEST" == "$CURRENT" ]]; then
msg_ok "${APP} is already at ${LATEST}"
exit
fi
msg_info "Updating ${APP} from ${CURRENT}${LATEST}"
systemctl stop "${APP}"
msg_info "Creating Backup" msg_info "Creating Backup"
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" "/opt/${APP}" tar -czf "/opt/discopanel_backup_$(date +%F).tar.gz" "/opt/discopanel"
msg_ok "Backup Created" msg_ok "Created Backup"
rm -rf /opt/${APP} rm -rf /opt/discopanel
msg_info "Downloading ${APP} ${LATEST}" fetch_and_deploy_gh_release "discopanel" "nickheyer/discopanel" "tarball" "/opt/discopanel"
git clone --branch "$LATEST" --depth 1 \
https://github.com/nickheyer/discopanel.git \
/opt/${APP}
msg_ok "Downloaded ${APP} ${LATEST}"
msg_info "Building frontend" msg_info "Building frontend"
cd /opt/${APP}/web/discopanel || exit cd /opt/discopanel/web/discopanel
npm install npm install
npm run build npm run build
msg_ok "Frontend Built" msg_ok "Builded frontend"
msg_info "Building backend" msg_info "Building backend"
cd /opt/${APP} || exit cd /opt/discopanel
go build -o discopanel cmd/discopanel/main.go go build -o discopanel cmd/discopanel/main.go
msg_ok "Backend Built" msg_ok "Builded backend"
echo "$LATEST" >/opt/${APP}_version.txt msg_info "Starting Service"
systemctl start discopanel
systemctl start "${APP}" msg_ok "Started Service"
msg_ok "Update Successful → now at ${LATEST}" msg_ok "Updated Successfully!"
fi
exit
} }
start start