#!/bin/bash
set -euo pipefail

title='Reset image'

if [[ -e /etc/image-live ]]; then
    zenity --error --title="${title}" \
        --text='Factory reset is available only after installation.'
    exit 1
fi

zenity --question --title="${title}" \
    --width=520 \
    --ok-label='Reset and restart' \
    --cancel-label='Cancel' \
    --text='<b>Delete all users, settings, applications, containers and other mutable data?</b>\n\nThe boot partition and both read-only A/B system slots are retained. This cannot be undone.' || exit 0

pkexec /usr/bin/systemctl start factory-reset.target
