#!/bin/bash -e

# This script is intended to be run in the Calamares post-installation stage,
# after the new system has been installed but before the first reboot.
# It performs final configuration steps before the user restarts into their new system.

TARGET=$(mount | grep proc | grep calamares | awk '{print $3}' | sed -e "s#/proc##g")

# Remove live-session dconf database and profile from the installed system.
# The live squashfs is what gets unpacked, so these files end up on disk and
# can cause the live wallpaper to persist into the installed session.
rm -rf "${TARGET}/etc/dconf/db/live.d"
rm -f  "${TARGET}/etc/dconf/db/live"
rm -f  "${TARGET}/etc/dconf/profile/live"
rm -f  "${TARGET}/lib/live/config/9999-vesperos-dconf"

# Recompile dconf databases without the live database present.
chroot "${TARGET}" dconf update
