#! /bin/bash

error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code

cp -RT $FAI/simplefiles/CONTESTANT $target

$ROOTCMD dconf update

# Enable firewall
$ROOTCMD systemctl enable nftables.service

# Disable Bluetooth
$ROOTCMD systemctl disable bluetooth.service

# Disable sleep
$ROOTCMD systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

sed -i 's|"homepage": ".*"|"homepage": "https://finals.soi.ch/"|' $target/etc/chromium/master_preferences

# Disable panels in gnome-control-center
DISABLE_DESKTOP="$ROOTCMD dpkg-statoverride --force-statoverride-add --update --add root root 640"
$DISABLE_DESKTOP /usr/share/applications/gnome-bluetooth-panel.desktop
$DISABLE_DESKTOP /usr/share/applications/gnome-online-accounts-panel.desktop
$DISABLE_DESKTOP /usr/share/applications/gnome-sharing-panel.desktop

# Auto login
sed -i 's/#  AutomaticLoginEnable = true/AutomaticLoginEnable = true/g' $target/etc/gdm3/daemon.conf
sed -i 's/#  AutomaticLogin = user1/AutomaticLogin = contestant/g' $target/etc/gdm3/daemon.conf

exit $error