#!/bin/sh
#
# /etc/X11/kdm/Xstartup
#
# This script is run as root after the user logs in.
# If this script exits with a return code other than 0, the user's
# session will not be started.

PATH=$PATH:/usr/bin/X11

if grep -qs ^ignore-nologin /etc/X11/kdm/kdm.options; then
  if [ -f /etc/nologin ]; then
    if command -v xmessage > /dev/null 2>&1; then
      xmessage -file /etc/nologin -geometry 640x480
    fi
  fi
elif [ -f /etc/nologin ]; then
  if command -v /usr/bin/X11/xmessage > /dev/null 2>&1; then
    xmessage -file /etc/nologin -geometry 640x480
  fi
  exit 1
fi

# insert a utmp entry for the session
if grep -qs ^use-sessreg /etc/X11/kdm/kdm.options; then
  exec sessreg -a -l $DISPLAY -u /var/run/utmp -x /etc/X11/kdm/Xservers $USER
  # NOTREACHED
fi

exit 0
