#!/usr/bin/bash# After an update, on the first login into the new system version: "Quine# Linux was updated from X to Y. Is everything working?" — Keep this update,# Roll back, or Ask me later. The same check layer-wizard does after layering# a package, for the nightly update (uupd) and anything else that changes# the deployment. Runs at login, as the user (/etc/xdg/autostart/# quine-update-confirm.desktop).## Each user keeps the deployment they last confirmed in# ~/.local/state/quine-linux/confirmed-deployment. No file yet (a new# install or user): today's deployment becomes the confirmed one, no# question. Roll back runs update-rollback through pkexec, which asks for an# admin password and restarts into the previous version.set -euo pipefail[ -e /run/ostree-booted ] || exit 0 # not an installed system (live ISO)command -v kdialog >/dev/null || exit 0state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/quine-linux"confirmed_file="$state_dir/confirmed-deployment"mkdir -p "$state_dir"status=$(rpm-ostree status --json)# rpm-ostree lists deployments staged first, then booted, then rollback.read -r booted new_version old_checksum old_version < <(jq -r '.deployments as $d| ($d | map(.booted) | index(true)) as $i| [$d[$i].checksum, ($d[$i].version // "?"),($d[$i + 1].checksum // "-"), ($d[$i + 1].version // "-")] | @tsv' <<<"$status")confirm() { printf '%s\n' "$booted" >"$confirmed_file"; }[ -s "$confirmed_file" ] || { confirm; exit 0; }[ "$(cat "$confirmed_file")" != "$booted" ] || exit 0# Layering a package with layer-wizard: it asks about that itself.if [ -e "$HOME/.local/state/layer_wizard/pending_confirmation.json" ]; thenconfirm; exit 0fi# Nothing to go back to: nothing to ask.[ "$old_checksum" != - ] || { confirm; exit 0; }from=""[ "$old_version" = - ] || [ "$old_version" = "$new_version" ] || from=" from $old_version"text="Quine Linux was updated$from to $new_version.Is everything working? If something broke, Roll back restarts the computer \into the version you had before. Ask me later asks again at your next login."answer=0kdialog --title "Quine Linux updated" --icon system-software-update \--yes-label "Keep this update" --no-label "Roll back" --cancel-label "Ask me later" \--warningyesnocancel "$text" || answer=$?case $answer in0) confirm ;;1)kdialog --title "Roll back" --icon edit-undo \--continue-label "Roll back and restart" \--warningcontinuecancel "Restart now into the version you had before? Save your work first." \|| exit 0if ! err=$(pkexec /usr/libexec/quine-linux/update-rollback 2>&1); thenkdialog --title "Roll back" --error "The rollback didn't start:${err:-cancelled}You'll be asked again at your next login."fi ;;*) ;; # ask me later: leave it unconfirmedesac