#!/bin/sh
#
# Screen script that launches xterm, mainly for troubleshooting.
#
# Copyright (c) 2011 Alkis Georgopoulos <http://alkisg.mysch.gr>
#
# This software is licensed under the GNU General Public License version 2,
# the full text of which can be found in the COPYING file.

. /usr/share/ltsp/screen-x-common
 
export HOME="${HOME:-/root}" USER="${USER:-root}"
COMMAND="xterm $*"

# The following logic is described at the top of xinitrc.
if [ -x /usr/share/ltsp/xinitrc ]; then
    xinit /usr/share/ltsp/xinitrc "$COMMAND" -- "$DISPLAY" "vt${TTY}" $X_ARGS >/dev/null
else
    eval "xinit $COMMAND -- $DISPLAY vt${TTY} $X_ARGS >/dev/null"
fi

if [ $? -ne 0 ]; then
    echo "Xserver failed, falling back to a text shell" >&2
    exec /bin/bash --login
fi
