#!/bin/bash
set -ex

if [[ -e /boot/switchroot/firstboot ]]; then
	# Ensure variables are being source
	source /boot/switchroot/firstboot
	# Create user with id 1000
	adduser -m -s /bin/bash -o -u 1000 "${USERNAME}"
	echo "${USERNAME}:${PASSWORD}" | chpasswd
	# Disable initial-setup
	systemctl disable initial-setup
	# Rewmove firstboot setup file
	rm /boot/switchroot/firstboot
fi

systemctl disable l4t-firstboot
rm -f "${0}"
