[comp.sys.hp] running X from init

kelso@seas.gwu.edu (John Kelso) (12/11/89)

I have been trying, without any luck, to have X started up by init, as
indicated in the Xserver manual page.  I am running on an HP 9000/340
workstation, using version 6.5.2 of HPUX.

If anyone out there has been able to pull this off, please let me know
via email.  I will post the results.

Thanks,

John Kelso

--
      John Kelso, System Engineer, George Washington University
     SEAS Computing Facility, 725 23rd St NW, Washington DC 20052
 	     kelso@seas.gwu.edu  -or-  uunet!gwusun!kelso
--

ken@hpubrcf.HP.COM (Ken Green) (12/13/89)

	This is one solution, not the best now, but doesn't rely on any non
	standard s/w.


is:2:initdefault:
st::sysinit:stty 9600 clocal icanon echo opost onlcr ienqak ixon icrnl ignpar < /dev/systty
bl::bootwait:/etc/bcheckrc </dev/syscon >/dev/syscon 2>&1 #bootlog
bc::bootwait:/etc/brc 1>/dev/syscon 2>&1 #bootrun command
cr::bootwait:/bin/cat /etc/copyright >/dev/syscon
lp::off:/bin/nohup /bin/sleep 999999999 < /dev/lp & stty 9600 < /dev/lp
lp:2:respawn:/bin/cat < /usr/spool/print > /dev/ser_think 
rc::wait:/etc/rc </dev/syscon >/dev/syscon 2>&1 #run com
pf::powerfail:/etc/powerfail 1>/dev/console 2>&1 #power fail routines
mu:2:wait:/etc/multi_user 0</dev/syscon 1>/dev/syscon 2>&1 #multi_user environment setup
co:1456:respawn:/etc/getty console H 
X0:2:respawn:env PATH=/bin:/usr/bin/X11:/usr/bin xinit -L =+512+300 ttyqf -- :0
r3:3:respawn:/etc/getty ite H

spirit@uxe.cso.uiuc.edu (12/13/89)

>>>
>>>I have been trying, without any luck, to have X started up by init, as
>>>indicated in the Xserver manual page.  I am running on an HP 9000/340
>>>workstation, using version 6.5.2 of HPUX.
>>>
>>>If anyone out there has been able to pull this off, please let me know
>>>via email.  I will post the results.
>>>
>>>Thanks,
>>>
>>>John Kelso

Yes John,

I have tried to get this information before.  I want to leave our
workstation running an X login window.  (Sounds reasonable to me.)
If you find out a way to do this, let me know!

Here is a work around I have used.  It is kind of ugly, but you 
might want to try it.

1)  Start X and leave it running in the background.  As far as a window
manager, the user will have to start that themselves.  I am not going
to let them "create window" as root or anybody else for that matter.

2)  Use the following line in your init, along with these two scripts.
You could probably two separate scripts.  (extra credit!)  Talk about
brute force.

Init Line:
X1:2:respawn:env PATH=/usr/bin:/usr/local/bin:/bin:/usr/bin/X11 /bin/sh /usr/local/bin/x_login

x_login script:
xterm -display uiatma:0.0 -geometry =80x40+10+20 %160x160 -bw 5 -132 -j -rw -ls  -sb -si -sk -sl 500 -fn hp8.10x20 -e /bin/sh /usr/local/bin/x_relogin

x_relogin script:
exec login

The one drawback to this method is that "login" times out every 60
seconds, but I don't know how much of a load that really is.

If it worked the way the manual says it does, then the question
would be moot.

spirit@uxe.cso.uiuc.edu

dme@doc.ic.ac.uk (Dave Edmondson) (12/15/89)

In article <47500019@uxe.cso.uiuc.edu> spirit@uxe.cso.uiuc.edu writes:
>>>
>>>I have been trying, without any luck, to have X started up by init, as
>>>indicated in the Xserver manual page.  I am running on an HP 9000/340
>>>workstation, using version 6.5.2 of HPUX.
>>>
>>>If anyone out there has been able to pull this off, please let me know
>>>via email.  I will post the results.
>>>
>>>Thanks,
>>>
>>>John Kelso

I have had xdm from the r3 distribution working with hp's r2 product,
and everything seems to go just fine.  We had to stop using that for
other reasons though, so I've had to solve a similar problem.

spirit> Here is a work around I have used.  It is kind of ugly, but you 
spirit> might want to try it.

Similar solution here, except that we restart the X server each time
the login window dies (or a person logs out).  This is quite important
here as our students do strange things to the server, and then it has
to be reset before the next person comes to use it.

In inittab I have :
X:2:respawn:/usr/lib/X11/xgetty/server >/tmp/errs 2>&1  # start an X server
where the errs file was just for testing.  The xgetty stuff looks like
this....

/usr/lib/X11/xgetty/server:
#!/bin/sh -
#
# dme
#
exec /usr/bin/X11/xinit /usr/lib/X11/xgetty/client -- /usr/bin/X11/Xhp

and.....

/usr/lib/X11/xgetty/client:
#!/bin/sh -
#
# dme
#
exec /usr/bin/X11/xterm -display :0 -T Console -n Console -geometry +10+10 -e /bin/login

You might want to tweak these accordingly.  It's interesting to note
that the pty allocated to the xterm started always seems to be
/dev/pty/ttyqd, but I've yet to fathom a good reason why that is the
case (this incidentally means that you can check for this in your
.login to start other X clients).  All in all, I'd prefer a cleverer
init (such as that provided with sunos4) where I can do (from ttytab) :

ttyx0   "/usr/lib/X11/xgetty/client"    xterms          on window="/usr/lib/X11/xgetty/server" secure

and be _sure_ which tty the xterm will end up on.

Hope this is of some help.

spirit> spirit@uxe.cso.uiuc.edu

dave.
--
Dave Edmondson.                                 Department of Computing,
     <dme@doc.ic.ac.uk>                         Imperial College,
     <dme@cc.ic.ac.uk>                          180 Queen's Gate,
                                                South Kensington, London.
 ``If you have A and you have B you can say A and B, but so what ?''
                                                --  Ruy de Querioz

tim@hpcpbla.HP.COM (Tim Phipps) (12/20/89)

> and be _sure_ which tty the xterm will end up on.

This inittab results in the login terminal running on ttyq0 and kills the
server when the window dies.

X:2:respawn:env PATH=/bin:/usr/bin/X11:/usr/bin xinit sh -c "xinitcolormap -f /usr/lib/X11/cmap.8.primary; exec hpterm -fg white -bg black =+200+150 -n Login -L ttyq0" -- -co /usr/lib/X11/rgb.big :0 #XWindows

/etc/ttytype can have an entry for ttyq0 to set the TERM variable
automatically.

I used to use the following for a while:

XX:2:respawn:/usr/bin/X11/X :0                                  #XServer
XC:2:respawn:/usr/bin/X11/hpterm -display local:0.0 -L ttyq0    #XClient

This does not kill the server when you quit the login window
but unless you kill all clients off before exiting the login window
the server will not reset and you may inherit someone else's resources if
they are stored in the server!  Besides that I only exit X when it gets
too big (not a memory leak just too many windows) and then I want to kill
it anyway.

Merry Christmas
Tim.

cary@hpclcac.HP.COM (Cary Coutant) (12/22/89)

Here's what I did to login to X:

1.  I added the following line to /etc/inittab.  Rather than running
    hpterm directly, I run a script that does a few other things as well.

	X0  : 2 :respawn:env PATH=/usr/bin/X11:/bin:/usr/bin xinit \
			/users/cary/bin/xstart.init ttyqf \
			-- :0 >>/tmp/xinit.log 2>&1

2.  I linked the ttyqf and ptyqf device files from the /dev/pty and
    /dev/ptym directories into /dev, because older hpterms couldn't
    find them otherwise:

	ln /dev/pty*/*qf /dev

    (I picked ttyqf arbitrarily.)

3.  I added the following line to /etc/gettydefs.  When hpterm runs
    getty, it uses an argument of "Xwindow".

	Xwindow# B9600 HUPCL PARENB CS7 # B9600 SANE PARENB CS7 ISTRIP IXANY TAB3 #X login: #9600

4.  The script /users/cary/bin/xstart.init starts up the clock and
    login window, and also loads my X defaults and sets the root
    window pattern:

	MYHOME=/users/cary

	: ${DISPLAY:=unix:0.0}; export DISPLAY
	TZ=PST8PDT
	export TZ

	xset b 60 880 100 s 1200
	xrdb -load $MYHOME/.X11defaults
	xsetroot -bg SeaGreen -fg Grey -mod 16 16
	xclock -geometry 128x128+10+10 &
	exec hpterm =80x24+10-10 -L "$@"

    The final argument to hpterm comes from the inittab line ("ttyqf").

5.  In my .profile, I test the tty to start up the rest of my clients.

	if [ `tty` = "/dev/ttyqf" ]
	then PATH=$HOME/X11/bin:/usr/local/bin/X11:/usr/contrib/X11Programs:/usr/bin/X11:$PATH
	     export PATH

	     : ${DISPLAY:=unix:0.0}
	     export DISPLAY

	     xsetup
	fi

Be careful!  When you logout of the initial login window, X will terminate
(and all the clients along with it), then init will respawn the whole
thing.  This sure makes it easy to shut down at the end of the day,
though.

If you want to login on the console without running X, you'll need to
change the run level to 1 (type "init 1" as root).  I considered setting
up the X stuff as run-level 3, and making that the default, but it hasn't
yet seemed necessary.

Cary Coutant, HP Systems Technology Division