source: lliurex-rpi-packages/trunk/fuentes/ldm/ltsp/screen.d/ldm @ 2328

Last change on this file since 2328 was 2328, checked in by kbut, 3 years ago

add new package

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#!/bin/sh
2# Depend on the ldm package
3#
4# Copyright 2005, Canonical Ltd.
5# Copyright 2006-2008 Vagrant Cascadian
6#
7# This program is free software; you can redistribute it and/or modify it under
8# the terms of the GNU General Public License as published by the Free Software
9# Foundation; either version 2, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT ANY
12# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13# PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License with your
16# Debian GNU system, in /usr/share/common-licenses/GPL.  If not, write to the
17# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18# 02111-1307, USA.
19
20#
21# Load code common to X based screen scripts
22#
23
24# NOTE: The while loop has been moved into screen_session (the parent script
25# to this one.  MAKE SURE YOU HAVE THE LATEST ltsp-trunk
26
27trap cleanup 0 INT QUIT TERM
28
29cleanup()
30{
31    if [ -d "${XAUTHORITY_DIR}" ]; then
32        rm -Rf "${XAUTHORITY_DIR}"
33    fi
34
35    if [ -f "${XAUTHORITY}" ]; then
36        rm -f "${XAUTHORITY}"
37    fi
38
39    if [ -f "/tmp/.X${TTY}-lock" ]; then
40        rm -f "/tmp/.X${TTY}-lock"
41    fi
42
43    if [ -S "/tmp/.X11-unix/X${TTY}" ]; then
44        rm -f "/tmp/.X11-unix/X${TTY}"
45    fi
46}
47
48. /usr/share/ltsp/screen-x-common
49# backwards compatibility: set DISPLAY from old DISP variable
50test -z "$DISPLAY" && DISPLAY="$DISP"
51XAUTHORITY_DIR=`mktemp -d /var/run/ldm-xauth-XXXXXXXXX`
52export XAUTHORITY_DIR
53XAUTHORITY="${XAUTHORITY_DIR}/Xauthority"
54touch $XAUTHORITY
55export XAUTHORITY
56
57SESSIONLIST="/etc/X11/xinit/Xsession \
58             /etc/X11/Xsession \
59             /usr/lib/X11/xdm/Xsession \
60             /etc/X11/xdm/Xsession"
61
62if [ -z "$LDM_LOGIN_TIMEOUT" ] && [ -n "$LDM_TIMEOUT_TIME" ] && [ -n "$LDM_TIMEOUT_ENABLED" ]; then
63    # implement backwards compatibility with short-lived timeout login options
64    if boolean_is_true "$LDM_TIMEOUT_ENABLED" ; then
65        LDM_LOGIN_TIMEOUT="$LDM_TIMEOUT_TIME"
66    fi
67fi
68
69#
70# Server scalability.  If there exists a /usr/share/ltsp/get_hosts file, then
71# use it to populate the LDM_SERVER environment variable.
72#
73
74if [ -z "${LDM_SERVER}" ]; then
75    if [ -x /usr/share/ltsp/get_hosts ]; then
76        LDM_SERVER=$(/usr/share/ltsp/get_hosts)
77    else
78        LDM_SERVER=${SERVER}
79    fi
80fi
81export LDM_SERVER
82
83#
84# Loop though each of the hosts, and get their ldminfo
85#
86
87if [ -n "${LDM_SERVER}" ]; then
88    test ! -d /var/run/ldm && mkdir -p /var/run/ldm
89    for SRV in $LDM_SERVER ; do
90        # Write server to /etc/hosts so reverse DNS lookup is not necessary
91        if ! grep -q "$SRV" /etc/hosts ; then
92            echo "$SRV  server-$SRV" >> /etc/hosts
93        fi
94        # For this to work, ldm-server needs to be installed in the chroot
95        if boolean_is_true "$LTSP_FATCLIENT" && [ -x /usr/share/ldm/ldminfod ]; then
96            /usr/share/ldm/ldminfod > /var/run/ldm/$SRV
97            break
98        else
99            nc $nc_q_param -w 5 $SRV 9571 > /var/run/ldm/$SRV
100        fi
101    done
102fi
103
104get_xfs_settings "$LDM_SERVER"
105
106MCOOKIE=$(mcookie)
107if [ -z "${MCOOKIE}" ]; then
108    echo "Couldn't create cookie"
109    exit 1
110fi
111
112# FIXME: This needs to non-destructively operate  in parallel with other
113# X servers running on the same machine.  See /usr/bin/startx for example.
114xauth -q add ${DISPLAY} . ${MCOOKIE} 2>/dev/null
115# Might not be necessary to do these...
116xauth -q add `hostname`${DISPLAY} . ${MCOOKIE} 2>/dev/null
117xauth -q add 127.0.0.1/unix${DISPLAY} . ${MCOOKIE} 2>/dev/null
118
119# Define our session
120if [ -z "${LDM_XSESSION}" ]; then        # If admin hasn't specified session
121    for SESSION in ${SESSIONLIST}; do
122        if [ -x ${SESSION} ]; then
123            export LDM_DEFAULT_XSESSION=${SESSION}
124            break
125        fi
126    done
127fi
128
129if [ -x /usr/share/ltsp/xinitrc ]; then
130    xinitrc=/usr/share/ltsp/xinitrc
131fi
132
133xinit $xinitrc /usr/sbin/ldm -- ${DISPLAY} vt${TTY} -auth ${XAUTHORITY} ${X_ARGS} -br >/dev/null 2>&1
Note: See TracBrowser for help on using the repository browser.