#!/bin/sh
# Makes greetd the boot target. Identical logic to hosts/touch-panel's own
# 0200-greetd.hook.chroot.
set -eu

. /etc/kitchen-display-agent/config.env

chmod 0755 /usr/local/bin/kiosk-session

if ! id greeter >/dev/null 2>&1; then
  useradd --system --create-home --home-dir /var/lib/greetd --shell /usr/sbin/nologin greeter
fi

systemctl enable greetd
systemctl set-default graphical.target
systemctl mask getty@tty1.service

mkdir -p "/home/${KIOSK_USERNAME}/.config/sway"
chown -R "${KIOSK_USERNAME}:${KIOSK_USERNAME}" "/home/${KIOSK_USERNAME}/.config"
