#!/bin/sh

touch /etc/hostname
echo "tuxedo" >  /etc/hostname
hostnamectl hostname tuxedo

cp -af /usr/share/tuxedo/gnome/oem-config/calamares.rules /etc/polkit-1/rules.d/

rm -rf /home/oem/Desktop/*

apt-get install gnome-kiosk gnome-kiosk-script-session -yqq
mkdir -p /home/oem/.local/bin/
cp -af /usr/share/tuxedo/gnome/oem-config/gnome-kiosk-script /home/oem/.local/bin/

cp /usr/share/tuxedo/gnome/oem-config/oem-accountservice /var/lib/AccountsService/users/oem

rm -f /etc/gdm/custom.conf
cp -af /usr/share/tuxedo/gdm3/custom.conf /etc/gdm3/custom.conf
cp -af /usr/share/tuxedo/gdm3/daemon.conf /etc/gdm3/daemon.conf

find /home/*/.config/autostart -name cryptshutdown* -delete
find /home/*/.config/autostart -name set-click* -delete
find /etc/skel/.config/autostart -name cryptshutdown* -delete
find /etc/skel/.config/autostart -name set-click* -delete
find /usr/local/bin -name cryptshutdown.sh -delete
find /usr/local/bin -name firstshutdown.sh -delete
find /usr/local/bin -name rmfirstshutdown.sh -delete

if lsblk | grep -q crypt_dev; then
    cp -af /usr/share/tuxedo/gnome/ubuntu2604/settings_crypt.conf /etc/calamares/settings.conf
    cp -rav /usr/lib/calamares/modules/lukschange /usr/lib/x86_64-linux-gnu/calamares/modules/
else
    cp -af /usr/share/tuxedo/gnome/ubuntu2604/settings.conf /etc/calamares/settings.conf
fi

ln -s /usr/share/tuxedo/scripts/ubuntu2604-install-default-snaps.sh /usr/share/tuxedo/scripts/install-default-snaps.sh

chown -R oem:oem /home/oem/

