You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-2.2-install/data/xautologin

66 lines
1.8 KiB

#!/bin/bash
# first param - autologin user
13 years ago
XUSER=${1:-guest}
# number of virtual console
TTYNUM=${2:-7}
# number of virtual console
DISPLAYNUM=${3:-\:0}
# write pid for init.d/xdm (detect X for this xautologin)
echo $BASHPID >/var/run/bash.pid
MAINLOOP=1
killXserver()
{
KILLXPID=$XPID
XPID=
MAINLOOP=
kill -9 $KILLXPID &>/dev/null
}
trap killXserver SIGTERM SIGINT SIGQUIT
# rerun x session for XUSER while not shutdown and bash not receivce TERM
while id $XUSER &>/dev/null &&
[[ -n $MAINLOOP ]] &&
[[ "$(rc-status -r)" != "shutdown" ]]
do
# perform user profile setting up
X ${DISPLAYNUM} vt${TTYNUM} &
XPID=$!
export DISPLAY=${DISPLAYNUM}
13 years ago
env USER=${XUSER} /usr/share/calculate/xdm/xdm --login || break
# write pam enviroment for pam_ck_connector
cat >/home/${XUSER}/.pam_environment <<EOF
CKCON_DISPLAY_DEVICE=
13 years ago
CKCON_X11_DISPLAY_DEVICE=/dev/tty${TTYNUM}
CKCON_X11_DISPLAY=${DISPLAYNUM}
EOF
# registry user in utmp and wtmp
sessreg -a -l ${DISPLAYNUM} ${XUSER}
# run x session for user XUSER in background
su - ${XUSER} -c 'source /etc/profile
# replace xinit for startx
xinit()
{
# if file is script run it throught bash
if file $1 | grep -1 "POSIX shell script"
then
/bin/bash $*
else
$*
fi
}
# run script start xsession
source /usr/bin/startx' &
# wait for right work trap SIGTERM
wait $!
# remove user from utmp and wtmp
sessreg -d -l ${DISPLAYNUM} ${XUSER}
# perform logout scripts for user
13 years ago
env USER=${XUSER} /usr/share/calculate/xdm/xdm --logout
[[ -n $XPID ]] && kill -9 $XPID
done
exit 0