IBM Support

How do I start an X Virtual Frame Buffer (VFB) with the Motif Window Manager (MWM) from inittab?

Question & Answer


Question

How do I start an X Virtual Frame Buffer (VFB) with the Motif Window Manager (MWM) from inittab?

Answer

Some database applications require an Xserver DISPLAY, which is used to render database forms or other graphical images.  Since the DISPLAY is only used for rendering, some vendors recommend the Xserver Virtual Frame Buffer (Xvfb).  Xvfb is an Xserver that can run on machines with no display hardware and no physical input devices. It emulates a dumb frame buffer that uses virtual memory.
XVFB prerequisite file sets:
Instructions from application vendors often recommend starting Xvfb by adding the xinit command to /etc/inittab.  The xinit command exits when the last client exits, so adding xinit to the /etc/inittab might result in respawning issues. The Xinit command was not designed for a headless environment.

A better method is to start X, then start a separate Motif Window Manager (MWM) to respawn.
 
*** This solution is not supported by IBM AIX Support. It is only provided as an example, implemented by some AIX customers with success.  Consult with your application vendor to determine whether the solution meets their requirements.
1) Create a script named /etc/rc.startMWM
#!/bin/ksh
####################################
# CUSTOMIZABLE VARIABLES
####################################
# DB_APP is a generic term for Database Application
# which often require this headless environment.  
# You can replace "DB_APP" with a string which is
# more applicable to your environment, but be sure
# to change all entries in this script, and in the
# /etc/inittab

# This is the logfile in inittab
MWMLOG=/tmp/DB_APP_MWM.log
# Sleep to allow Xserver to start
XSERVER_SLEEP=10
# Sleep time between checks for running MWM
PS_SLEEP=60
# DB_APP_Xvfb Display Number
DISPNUM=10
# Added a debug flag (yes or no)
SCRIPT_DEBUG="no"
#####################################
# END OF CUSTOMIZABLE VARIABLES
#####################################
# MAIN SCRIPT
typeset -l SCRIPT_DEBUG
sleep $XSERVER_SLEEP
# Log a Time Stamp
/usr/bin/date
# Start the Window Manager required by DB_APP
export DISPLAY=":$DISPNUM"
while [ true ]
  do
    mwm_pid=`ps ax | egrep mwm | grep -v grep |awk '{print $1}'`
      if [ -z "$mwm_pid" ]
        then
          prochk=0
     # We did not find mwm in the process listing and need to start it
     
 else

 
# Check lines for line wrap. Must be one line, or use "\" to wrap!!
       prochk=$(ps ewwaux $mwm_pid| grep mwm | grep "DISPLAY=$DISPLAY" | grep "\-multiscreen" | egrep -v grep | wc -l)
      fi
      if [[ $prochk -eq 0 ]] ;
      then
     
# Log a Time Stamp
        /usr/bin/date
         printf "Starting the MWM Window Manager\n"
       
# Start the MWM Window Manager
        /usr/bin/X11/mwm -display $DISPLAY -multiscreen &
       
# Allow all hostnames access to connection
        xhost + >> $MWMLOG 2>&1 #Recommended to add specific hostnames
          # Additional Debugging to check xhost after last add
            if [[ $SCRIPT_DEBUG == "yes" ]] ;
              then
                OFS=$IFS
                IFS="|";printf "DEBUG: %s: Checking xhost\n\t..." $(date +"%a %b %e %H:%M:%S %Z %Y")
                IFS=$OFS
                xhost
            fi
 # XHOST NOTES
 
        # It is more secure to use xauth.  Users will need to consult with 
        # their security and database teams to determine the best method
        # to grant access.  
# See AIX X11: How to create and share .Xauthority for an X Virtual Frame Buffer Xserver
# https://www.ibm.com/support/pages/node/6846152
        # If you use xhost, it is more secure to add specific hostnames
        # instead of using "xhost +"
        # e.g 'xhost +hostname1 hostname2 hostname3 hostname4
        #
        # This can also be specified in /etc/X10.hosts
        #(Xnn.hosts, where 'nn' is the display number)
        # vi /etc/X10.hosts and add hostnames, one per line, no comments.
        # hostname1
        # hostname2
        # hostname3

      # Put this in foreground so we keep this alive
      fg %1
    fi
  # Sleep for a while here, before checking for the MWM process again
  sleep $PS_SLEEP
done



2) Add the following to /etc/inittab

Be sure to use the GLX: $DISPNUM that corresponds to your script. "10" is used in this example.

(Two single-line entries)
DB_APP_Xvfb:2:respawn:/usr/bin/X11/X -force -vfb -x abx -x dbe -x GLX :10  >/tmp/DB_APP_Xvfb.log 2>&1  # Start X VFB
DB_APP_MWM:2:respawn:/etc/rc.startMWM >> /tmp/DB_APP_MWM.log  2>&1  #Start MWM

3) Cleaning up the log file

This script does not create a new log file, as the testing users required ongoing logging. You can empty this file by running the following:
# echo > /tmp/DB_APP_MWM.log 

 
SUPPORT
*** This solution is not supported by IBM AIX Support. It is only provided as an example, implemented by some AIX customers with success.  Consult with your application vendor to determine whether the solution meets their requirements.

If X11 assistance is required, use the following step-by-step instructions to contact IBM to open a case for software with an active and valid support contract.  

1. Document (or collect screen captures of) all symptoms, errors, and messages related to your issue.

2. Capture any logs or data relevant to the situation.

3. Contact IBM to open a case:

   -For electronic support, see the IBM Support Community:
     https://www.ibm.com/mysupport
   -If you require telephone support, see the web page:
      https://www.ibm.com/planetwide/

4. Provide a clear, concise description of the issue.

 - For more information, see: Working with IBM AIX Support: Describing the problem.

5. If the system is accessible, collect a system snap, and upload all of the details and data for your case.

 - For more information, see: Working with IBM AIX Support: Collecting snap data

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"Component":"X11","Platform":[{"code":"PF002","label":"AIX"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
07 December 2022

UID

isg3T1024557