blob: be68040e231fbaa3ccdb5b8053273dfd6d892d22 [file] [log] [blame]
ohair7aae9af2009-11-08 15:11:10 -08001#!/bin/sh -f
2#
3# Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
9# particular file as subject to the "Classpath" exception as provided
10# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23# CA 95054 USA or visit www.sun.com if you need additional information or
24# have any 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"
62if [ ! -x ${WM} ] ; then
63 WM="/opt/sfw/bin/fvwm2"
64fi
65#
66# Wait for Xvfb to initialize:
67sleep 5
68#
69if [ -x "${WM}" ]; then
70# 2 JCK tests require a window manager
71# mwm fails (key name errors) and twm fails (hangs),
72# but fvwm2 works well.
73 /usr/bin/nohup ${WM} -display ${DISPLAY} -replace -f /dev/null > ${currentDir}/nohup.$$ 2>&1 &
74else
75 echo "Error: ${WM} not found"
76 exit 1
77fi
78#
79# Wait some more to see if the xhost command gets through:
80sleep 10
81# Allow access to all - this is a brute force approach,
82# but I do not see how it could be a security problem...
83DISPLAY="${DD}" xhost +
84#
85echo "Virtual frame buffer started on ${DISPLAY}"
86echo "$$" > $1
87wait