source: lmd-client/trunk/fuentes/install/usr/share/ltsp/screen.d.diversions/ldm.lliurex @ 839

Last change on this file since 839 was 839, checked in by mabarracus, 4 years ago

Fixed X startup

  • Property svn:executable set to *
File size: 4.9 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 boolean_is_true "$LDM_DIRECTX" ; then
130    if [ $({ echo "1.17"; X -version 2>&1 | sed -n 's/X.Org X Server //p';} | sort -V | head -n 1) = "1.17" ]; then
131        # Xorg after 1.17 needs `-listen tcp`, see
132        # http://cgit.freedesktop.org/xorg/xserver/commit/?id=cc59be38b7eff52a1d003b390f2994c73ee0b3e9
133        X_ARGS="-listen tcp $X_ARGS"
134    fi
135else
136    X_ARGS="-nolisten tcp $X_ARGS"
137fi
138
139xinitrc=/usr/share/ltsp/xinitrc
140
141# LLIUREX EDIT
142
143case $LDM_LANGUAGE in
144
145        "es_ES.UTF-8" | "es.UTF-8")
146                IMG_LANG="es"
147        ;;
148       
149        "ca_ES.UTF-8@valencia" | "ca_ES.UTF-8" )
150                IMG_LANG="val"
151        ;;
152       
153        *)
154                IMG_LANG="en"
155        ;;
156       
157esac
158
159eval $(getltscfg -a | grep -v export)
160result=$(echo $LTSP_FATCLIENT | grep -iq "true" && echo 1 || echo 0)
161if [ "$result" =  "1" ]; then
162        cp /usr/share/ldm/themes/lliurex/bg_fat_$IMG_LANG.png /usr/share/ldm/themes/lliurex/bg.png || true
163else
164        cp /usr/share/ldm/themes/lliurex/bg_thin_$IMG_LANG.png /usr/share/ldm/themes/lliurex/bg.png || true
165fi
166
167LANG=$LDM_LANGUAGE xinit $xinitrc /usr/sbin/ldm -- ${DISPLAY} vt${TTY} -auth ${XAUTHORITY} ${X_ARGS} -br >/dev/null 2>&1
168
Note: See TracBrowser for help on using the repository browser.