#!/bin/bash

# Set up the unique identifier at /etc/machine-id. D-Bus and pretty much
# everything else requires this.
# At the time of execution of this script, the root filesystem or at least
# where /etc resides should be read-write.
systemd-machine-id-setup
clear

# Launch the wizard.
/usr/libexec/aosc-os-oobe/aosc-os-oobe-cli

source /etc/locale.conf
export LANG

export TEXTDOMAIN=aosc-os-oobe-launcher

PROMPT=$"Please wait while the setup program performs one last cleanup operation.
Your device will reboot automatically once it is finished."
# Clean up
echo -e "$PROMPT"

# Remove itself.
oma --no-check-dbus --no-progress --no-bell purge --yes aosc-os-oobe-cli
oma --no-check-dbus --no-progress --no-bell autoremove --yes

# Apply the static hostname to the transient hostname.
HOSTNAME="$(hostnamectl hostname --static)"
export HOSTNAME
hostnamectl hostname --transient "$HOSTNAME"

# Apply the transient machine ID.
systemd-machine-id-setup --commit

sync
reboot -f
