1#!/bin/sh -f 2# 3# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5# 6# This code is free software; you can redistribute it and/or modify it 7# under the terms of the GNU General Public License version 2 only, as 8# published by the Free Software Foundation. Oracle designates this 9# particular file as subject to the "Classpath" exception as provided 10# by Oracle in the LICENSE file that accompanied this code. 11# 12# This code is distributed in the hope that it will be useful, but WITHOUT 13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15# version 2 for more details (a copy is included in the LICENSE file that 16# accompanied this code). 17# 18# You should have received a copy of the GNU General Public License version 19# 2 along with this work; if not, write to the Free Software Foundation, 20# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21# 22# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23# or visit www.oracle.com if you need additional information or have any 24# questions. 25# 26 27# 28# Original Author: Tim Bell 29# 30usage() { 31 echo "Starts up an Xvfb dummy X server with fvwm2 window manager" 32 echo " usage:" 33 echo " ${0} display_number_file" 34 echo " display_number_file gets display number when it's ready" 35 exit 36 } 37# 38currentDir=`pwd` 39rm -f $1 40DD=":$$" 41DISPLAY=${DD} 42export DISPLAY 43cd /tmp 44# 45if [ ! -x "/usr/bin/X11/Xvfb" ]; then 46 # We have Solaris-flavored X windows, and the /usr/openwin Xvfb is 47 # a simple wrapper script around the Xsun server. Massage the 48 # arguments: server number must be first; others are slightly 49 # different. 50 # 51 # Also the default Visual Class (DirectColor) triggers an awt bug 52 # (probably 4131533/6505852) and some tests will loop endlessly 53 # when they hit the display. The workaround is: 54 # 1) Ask for PseudoColor instead. 55 # 2) Omit 32-bit depth. 56 /usr/bin/nohup /usr/openwin/bin/Xvfb ${DISPLAY} -dev vfb screen 0 1280x1024x24 pixdepths 8 16 24 defclass PseudoColor > ${currentDir}/nohup.$$ 2>&1 & 57else 58 # Linux... 59 /usr/bin/nohup /usr/bin/X11/Xvfb -fbdir ${currentDir} -pixdepths 8 16 24 32 ${DISPLAY} > ${currentDir}/nohup.$$ 2>&1 & 60fi 61WM="/usr/bin/X11/fvwm2" 62# 63# Wait for Xvfb to initialize: 64sleep 5 65# 66if [ -x "${WM}" ]; then 67# 2 JCK tests require a window manager 68# mwm fails (key name errors) and twm fails (hangs), 69# but fvwm2 works well. 70 /usr/bin/nohup ${WM} -display ${DISPLAY} -replace -f /dev/null > ${currentDir}/nohup.$$ 2>&1 & 71else 72 echo "Error: ${WM} not found" 73 exit 1 74fi 75# 76# Wait some more to see if the xhost command gets through: 77sleep 10 78# Allow access to all - this is a brute force approach, 79# but I do not see how it could be a security problem... 80DISPLAY="${DD}" xhost + 81# 82echo "Virtual frame buffer started on ${DISPLAY}" 83echo "$$" > $1 84wait 85