Urgent help request! was Re: how do you get something to run when a user logs on?

Gavin McCullagh gmccullagh at gmail.com
Mon Sep 1 21:22:37 BST 2008


Hi,

as promised, a little more detail (I was a little busy earlier, sorry).

On Sun, 31 Aug 2008, john wrote:

> This issue is I want to run some scripts that up until now have been
> called by /etc/profile. This has worked for me up through Edubuntu
> 7.04 The scripts use the system variables $HOME and $USER to map NFS
> shares to users desktops. I understand from oli and others that the
> image generated by 8.04 doesn't reference /etc/profile when users log
> in.
> 
> When I tried calling these scripts from
> /etc/X11/Xsession.d per Ollies suggestion the scripts didn't seem to
> run, and in fact after accepting my credentials X just sent me back to
> the login screen,  perhaps my syntax was incorrect. But I couldn't
> find any debug information in the logs to trouble shoot the issue.
> Where do I find more debug info?

Actually, what Ollie is doing is sending you down a path which is more
consistent with regular (not thin client) desktops.  This is probably for
the best in general.  As far as I know, /etc/profile only gets run when a
shell such as bash gets started.  Environment variables are then inherited
by processes spawned by that shell.  In the old LTSP case, the first thing
which happens is the thin client connects via ssh to the server, which
spawns a shell (bash) which in turn spawns gnome, etc.  As a result,
/etc/profile worked for setting things within thin clients.  However, it
probably didn't work for old LTSP and it wouldn't work on installed
desktops which use GDM (the display manager) as those spawn gnome directly
without starting a bash shell.

The process is that /etc/X11/Xsession gets run and it in turn includes
these lines:

	# use run-parts to source every file in the session directory; we source
	# instead of executing so that the variables and functions defined above
	# are available to the scripts, and so that they can pass variables to each
	# other
	SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
	if [ -n "$SESSIONFILES" ]; then
	  set +e
	  for SESSIONFILE in $SESSIONFILES; do
	    . $SESSIONFILE
	  done
	  set -e
	fi

which says something like "for each file in /etc/X11/Xsession.d/, execute
that code within this script".  Because your script had an exit in it, that
effectively put an early exit inside the script above which is why your
script broke your login.

> francois suggestion about putting the lines in
> /opt/ltsp/i386/etc/profile and then updating the image didn't work
> either.

I'm pretty sure this is incorrect.  The Xsession runs on the server so the
XSession scripts that get run are those of the server.

As regards debugging, I suggest writing the output of commands and stuff
into a file such as /tmp/xsession-$USER.txt.  That way you can get an idea
how things went and put in debug statements to see the value of certain
variables at the time the script ran.

Gavin




More information about the edubuntu-users mailing list