improve update script

This commit is contained in:
Wendy Liga 2025-12-27 20:55:22 +07:00
parent 5698870c63
commit d85e518d9f
No known key found for this signature in database

View File

@ -29,44 +29,32 @@ function update_script() {
exit exit
fi fi
# Get latest version from GitHub if check_for_gh_release "Fladder" "DonutWare/Fladder"; then
RELEASE=$(get_latest_github_release "DonutWare/Fladder") msg_info "Stopping Service"
if [[ -z "$RELEASE" ]]; then systemctl stop nginx
msg_error "Failed to fetch latest release version from GitHub" msg_ok "Stopped Service"
exit 1
msg_info "Backing up configuration"
if [[ -f /opt/fladder/assets/config/config.json ]]; then
cp /opt/fladder/assets/config/config.json /tmp/fladder_config.json.bak
msg_ok "Configuration backed up"
fi
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Fladder" "DonutWare/Fladder" "prebuild" "latest" "/opt/fladder" "Fladder-Web-*.zip"
msg_info "Restoring configuration"
if [[ -f /tmp/fladder_config.json.bak ]]; then
mkdir -p /opt/fladder/assets/config
cp /tmp/fladder_config.json.bak /opt/fladder/assets/config/config.json
rm -f /tmp/fladder_config.json.bak
msg_ok "Configuration restored"
fi
msg_info "Starting Service"
systemctl start nginx
msg_ok "Started Service"
msg_ok "Updated successfully!"
fi fi
msg_info "Stopping Service"
systemctl stop nginx
msg_ok "Stopped Service"
msg_info "Backing up configuration"
if [[ -f /opt/fladder/assets/config/config.json ]]; then
cp /opt/fladder/assets/config/config.json /tmp/fladder_config.json.bak
msg_ok "Configuration backed up"
fi
msg_info "Updating ${APP} to ${RELEASE}"
cd /opt
wget -q "https://github.com/DonutWare/Fladder/releases/download/${RELEASE}/Fladder-Web-${RELEASE#v}.zip"
rm -rf /opt/fladder
unzip -q "Fladder-Web-${RELEASE#v}.zip" -d fladder
rm -f "Fladder-Web-${RELEASE#v}.zip"
echo "${RELEASE}" > ~/.fladder
msg_ok "Updated ${APP} to ${RELEASE}"
msg_info "Restoring configuration"
if [[ -f /tmp/fladder_config.json.bak ]]; then
mkdir -p /opt/fladder/assets/config
cp /tmp/fladder_config.json.bak /opt/fladder/assets/config/config.json
rm -f /tmp/fladder_config.json.bak
msg_ok "Configuration restored"
fi
msg_info "Starting Service"
systemctl start nginx
msg_ok "Started Service"
msg_ok "Updated successfully!"
exit exit
} }