clean up update function

This commit is contained in:
connorjfarrell 2025-01-24 10:26:18 -06:00 committed by GitHub
parent 691c9209dd
commit 17b23ba04b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,33 +33,19 @@ function update_script() {
RELEASE=$(curl -fsSL https://api.github.com/repos/ZoneMinder/zoneminder/releases/latest | grep -Po '"tag_name": "\K.*?(?=")') RELEASE=$(curl -fsSL https://api.github.com/repos/ZoneMinder/zoneminder/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null || echo 'none')" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null || echo 'none')" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
msg_info "Updating $APP" msg_info "Updating to v${RELEASE}"
msg_info "Stopping $APP"
systemctl stop zoneminder systemctl stop zoneminder
msg_ok "Stopped $APP"
msg_info "Creating Backup"
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /etc/zm /usr/share/zoneminder /var/cache/zoneminder
msg_ok "Backup Created"
msg_info "Updating $APP to v${RELEASE}"
apt-get update && apt-get install --only-upgrade zoneminder -y apt-get update && apt-get install --only-upgrade zoneminder -y
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting $APP"
systemctl start zoneminder systemctl start zoneminder
sleep 2 sleep 2
msg_ok "Started $APP"
msg_info "Cleaning Up"
rm -rf /tmp/zoneminder-update
msg_ok "Cleanup Completed"
echo "${RELEASE}" >/opt/${APP}_version.txt echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Update Successful" msg_ok "Update Successful"
else else
msg_ok "No update required. ${APP} is already at v${RELEASE}" msg_ok "${APP} is already v${RELEASE}"
fi fi
exit exit
} }