ohair | 7aae9af | 2009-11-08 15:11:10 -0800 | [diff] [blame] | 1 | #!/bin/sh -f |
| 2 | # |
ohair | 2283b9d | 2010-05-25 15:58:33 -0700 | [diff] [blame] | 3 | # Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
ohair | 7aae9af | 2009-11-08 15:11:10 -0800 | [diff] [blame] | 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 |
ohair | 2283b9d | 2010-05-25 15:58:33 -0700 | [diff] [blame] | 8 | # published by the Free Software Foundation. Oracle designates this |
ohair | 7aae9af | 2009-11-08 15:11:10 -0800 | [diff] [blame] | 9 | # particular file as subject to the "Classpath" exception as provided |
ohair | 2283b9d | 2010-05-25 15:58:33 -0700 | [diff] [blame] | 10 | # by Oracle in the LICENSE file that accompanied this code. |
ohair | 7aae9af | 2009-11-08 15:11:10 -0800 | [diff] [blame] | 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 | # |
ohair | 2283b9d | 2010-05-25 15:58:33 -0700 | [diff] [blame] | 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. |
ohair | 7aae9af | 2009-11-08 15:11:10 -0800 | [diff] [blame] | 25 | # |
| 26 | |
| 27 | # |
| 28 | # Original Author: Tim Bell |
| 29 | # |
| 30 | usage() { |
| 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 | # |
| 38 | currentDir=`pwd` |
| 39 | rm -f $1 |
| 40 | DD=":$$" |
| 41 | DISPLAY=${DD} |
| 42 | export DISPLAY |
| 43 | cd /tmp |
| 44 | # |
| 45 | if [ ! -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 & |
| 57 | else |
| 58 | # Linux... |
| 59 | /usr/bin/nohup /usr/bin/X11/Xvfb -fbdir ${currentDir} -pixdepths 8 16 24 32 ${DISPLAY} > ${currentDir}/nohup.$$ 2>&1 & |
| 60 | fi |
| 61 | WM="/usr/bin/X11/fvwm2" |
| 62 | if [ ! -x ${WM} ] ; then |
| 63 | WM="/opt/sfw/bin/fvwm2" |
| 64 | fi |
| 65 | # |
| 66 | # Wait for Xvfb to initialize: |
| 67 | sleep 5 |
| 68 | # |
| 69 | if [ -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 & |
| 74 | else |
| 75 | echo "Error: ${WM} not found" |
| 76 | exit 1 |
| 77 | fi |
| 78 | # |
| 79 | # Wait some more to see if the xhost command gets through: |
| 80 | sleep 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... |
| 83 | DISPLAY="${DD}" xhost + |
| 84 | # |
| 85 | echo "Virtual frame buffer started on ${DISPLAY}" |
| 86 | echo "$$" > $1 |
| 87 | wait |