#!/sbin/sh # $Id: init,v 1.2 1998/02/28 21:25:54 chris Exp $ # # $Revision: 1.2 $ $State: Exp $ # $Date: 1998/02/28 21:25:54 $ # # Xkernel init program # # Purpose, perform all commands required to get machine ready to run # the X server processes (Xsun). # # Copyright (c) 1992,1993 Seth Robertson # seth@ctr.columbia.edu ######################################## # Set up frequently used variables # PATH=/sbin:/; export PATH HOME=/; export HOME # These paths must refer to the NFS-root, not the server's root. Xserver=/Xsun; export Xserver Xrgb=/usr/lib/X11/rgb ######################################## # Shell functions shcat () { while read i do echo "$i" done } busy_loop () { shcat < /sbin/message.busy_loop while : do : done exit 3 } ######################################## # Last resort for Debugging # # This will not actually print anything on the screen, but it might # give a hint to someone who is having problems. # # The reason why I did this instead of something more informative is # because as far as I know, there is NO way I can influence ANYTHING # without /dev/console (even the fs is ro) # if [ ! -c /dev/console ]; then echo SOL exit 2 else echo /sbin/init is running > /dev/console fi ######################################## # Single user mode # echo checking for single user mode... >/dev/console if [ "x$1" = "x-s" ];then (/sbin/sh) > /dev/console 2>&1 < /dev/console fi ######################################### # Set up the I/O stuff # echo setting up the i/o stuff... >/dev/console exec >/dev/console 2>&1 ######################################## # Debugging warnings # echo making sure server $Xserver and /etc/hosts exists... >/dev/console if [ ! -x $Xserver -o ! -f /etc/hosts ] then shcat < /sbin/message.nofile busy_loop fi ######################################## # Configure the loopback interface # I do not know if this is necessary, but # it should not hurt. # echo configuring loopback... >/dev/console ifconfig lo0 127.0.0.1 up ######################################## # Configure the external interface, if possible # # If you have multiple ifconfig_cmd commands (for example if you have # both 3/50s and 3/180--meaning both le0 and ie0 interfaces), you # should be able to have both present. You will get an error message, # but you can ignore it. # # If you have machines with different BROADCAST or NETMASK needs but # with the same INTERFACE, you must either have seperate /export/root # directories for them, or you must do some "case" or "if" switching # on the `hostname` # # I understand Sun has some new wierd hostconfig stuff which will use # bootparams and other things to set the up for you. I never bothered # with it and I think it is only available for Sun 4s anyway. # # Of course, if the default settings of the interface is fine, then # remove /etc/ifconfig_cmd* # for f in /etc/ifconfig_cmd.* do echo invoking the command file $f >/dev/console sh -c $f done ######################################## # Set up default router # # If you have specified a default route, this will set it up for you. # If you have hosts which need different default routes, then you # either can do case or if switching on `hostname` or you can make a # statically linked version of in.routed or in.gated. If you know # what I am talking about, and need to, then go for it. # if [ -f /etc/defaultrouter ]; then read defaultrouter < /etc/defaultrouter echo adding defaultrouter $defaultrouter >/dev/console route add default $defaultrouter 1 fi ######################################## # Mount NFS filesystems. # # Under normal Xkernel 2.0 setup, you do NOT need to perform ANY NFS # mounts yourself. The root directory is mounted by the kernel, and # you need nothing else. However, it is possible that because of some # local wierdity (e.g. you cannot run the font server) you must mount # some NFS file systems. Now is a good time. # echo might want to mount /etc/fstab stuff >/dev/console if [ -f /etc/fstab ]; then echo yup... mounting nfs... >/dev/console mount -antv nfs fi ######################################## # More terminal error checking # This must be getting it from the NFS root, not the real disk; # these files are there so we're OK here. if [ ! -f $Xrgb.pag -o ! -f $Xrgb.dir ] then shcat < /sbin/message.norgb busy_loop fi ######################################## # Set the date (if you like your syslog messages to be correct) # #/sbin/rdate -s primaryxdmhost ######################################## # Start up system message logging # # This is not absolutely necessary, but by default, kernel printfs are # turned off (otherwise they mess up the graphics device in X). The # message which the kernel might have printed might well be of # interest, so this will forward the syslog message to loghost. # # If you want to see kernel printfs, read the Xpert FAQ, # or if you know what you are doing, use adb to set # noprintf to 0 in vmunix # # vanilla syslogd will die a horrible death # if [ -f /etc/syslog.conf -a -f /sbin/syslogd ]; then echo running syslogd... >/dev/console syslogd fi ######################################## # Clear sockets # # This is to prevent a problem we have with fontserver # (namely Xsun will use the same socket to contact # the fontserver and then both will get confused) # # This uses a random number of socket so that Xsun # will hopefully use a different one when it talks # to the fontserver echo clearing sockets for fontserver... >/dev/console clearsockets fontserver # ERROR: "connect: Connection refused; errno=61" echo hopefully cleared >/dev/console ######################################## # Start Xsun # # If we were feeling confident we could exec it... # # You may ignore the message about the Unix Domain socket if # the X server does not exit because of it. See -pn below # # # Xsun has billions of options. RTFM for Xsun and Xserver # Just as a quick description of the ones I use. # # -pn Partial Network. This prevents the X server from exiting if # it cannot, for instance, establish the Unix Domain socket for # communications with the X server. This is good, since we do # not have a /tmp and it would not be writable if we did have # it. You will still get the error message, but it can be # safely ignored. # # -indirect XDMCP indirect logins. This option tells the X server to # use XDMCP (which provides some security and allows xhosts from # remote machines) and to use the indirect option to XDM. This # means that the chooser stuff will be executed by the remote # XDM. This allows the user at the X terminal to choose which # host it wants to log in to. # # -query XDMCP direct logins. I use indirect over direct now, but for # your application, you may wish to use this instead. This # option just bypasses the menu which allows you to select which # host you want to log in to. # # -fp This is the font server option. This option tells the X # server that instead of getting the fonts from the Unix # filesystem (read via NFS) it should contact a font server. # Read fs(1) for more information. (Thanks to Jay Bourland # for getting me the scoop on this # option). # # If you are having problems, delete the /dev/null or /dev/log redirections # # # If you need to exec different Xsun depending on the host (e.g. some # machines are color and some monochrome and you want to use the # smaller mono-only version on the monochrome versions) you can either # generate an extra /export/root for the color machines, or you can do # something like: # #case `hostname` in # sinope*|rousseau*|callisto*|ganymede*) Xserver=/Xsuns/Xsun;; #esac # echo building FONTPATH >/dev/console FONTPATH=/usr/lib/X11/fonts; export FONTPATH if [ -d $FONTPATH ]; then echo found a FONTPATH=$FONTPATH >/dev/console # Hmm, we have a font directory, so we must be using NFS for fonts. for i in $FONTPATH/*; do if [ -f $i/fonts.dir ]; then FP="${FP:+$FP/,}$i" fi done else # Font server standard port is 7100. FP="tcp/fontserver:7100/all" echo didnt find a FONTPATH so use FP=$FP >/dev/console fi # change -indirect to -query if desired, below. XDMCMD="-indirect primaryxdmhost" #XDMCMD="-query primaryxdmhost" # Must use NFS-root version of the color database, not X11R6's # unless we want to NFS mount that on top or something goofy. # -co /usr/X11R6/lib/X11/rgb XSRVCMD="$Xserver -fp $FP -co $Xrgb -pn $XDMCMD" echo starting X server with $XSRVCMD >/dev/console if [ -x /sbin/syslogd -a -f /etc/syslog.conf -a -p /dev/log ]; then # Runs this one! echo To devlog... $XSRVCMD >/dev/log 2>&1 else echo To stdout/err $XSRVCMD # >/dev/null 2>&1 fi ######################################## # We should never get here. # shcat < /sbin/message.Xterm busy_loop