#!/bin/sh
set -eu
. /usr/lib/newworld-installer/mode
ensure_normal_install
state=/run/newworld-install
if [ ! -f "$state/target-ready" ] || [ -f "$state/error" ]; then
    echo 'The installed system has not passed final verification.' >"$state/error"
    /usr/lib/newworld-installer/usb-log finish failed >/dev/null 2>&1 || true
    while :; do sleep 60; done
fi
# All target-changing D-I hooks have finished, including the final random seed.
# Flush their writes, then close the USB log while the medium is still mounted.
sync
/usr/lib/newworld-installer/usb-log finish ok >/dev/null 2>&1 || true
sync
touch "$state/completed"
logger -t newworld 'Installation complete: 100%.'
sleep 3
