#!/bin/bash
set -ex

if [[ -e /boot/switchroot/firstboot ]]; then
	source /boot/switchroot/firstboot
	adduser -G audio,video,wheel,input -m -s /bin/bash -o -u 1000 "${USERNAME}"
	echo "${USERNAME}:${PASSWORD}" | chpasswd
	rm /boot/switchroot/firstboot
	sudo -u "${USERNAME}" systemctl --user enable --now auto-rotate
	systemctl disable --now initial-setup l4t-firstboot
	rm /usr/share/xsessions/openbox.desktop
	update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/konsole 50
	sed -i s/FirewallBackend=.*/FirewallBackend=iptables/g /etc/firewalld/firewalld.conf
fi

rm "${0}"
