~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to buildout-templates/bin/with-xvfb.in

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-09-12 09:23:01 UTC
  • mfrom: (7675.1045.783 db-devel)
  • Revision ID: launchpad@pqm.canonical.com-20110912092301-jfzipjl4a97d8xxw
Merging db-stable at revno 10966

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# Copyright 2011 Canonical Ltd.  This software is licensed under the
 
4
# GNU Affero General Public License version 3 (see the file LICENSE).
 
5
#
 
6
# Wrapper that provides a default Xvfb environment for the given
 
7
# command.
 
8
#
 
9
# If the command is not found it is searched for in the same directory
 
10
# as this script. This lets you do `bin/with-xvfb iharness` for
 
11
# example.
 
12
#
 
13
# Follows sinzui's advice to the launchpad-dev list:
 
14
#   https://lists.launchpad.net/launchpad-dev/msg07879.html
 
15
#
 
16
 
 
17
set -eu
 
18
 
 
19
# Look for $1 - i.e. the command to run - in this script's directory
 
20
# if it's not found along the default PATH.
 
21
if [ $# -ge 1 ] && ! type -P "$1" > /dev/null
 
22
then
 
23
    if command="$(PATH="$(dirname "$0")" type -P "$1")"
 
24
    then
 
25
        # Shift $1 off and set new positional arguments.
 
26
        shift && set -- "$${command}" "$@"
 
27
    fi
 
28
# If no command has been given and SHELL is set, spawn a shell.
 
29
elif [ $# -eq 0 -a -n "$${SHELL:-}" ]
 
30
then
 
31
    set -- "$${SHELL}"
 
32
fi
 
33
 
 
34
#
 
35
# --auto-servernum
 
36
#   Try to get a free server number, starting at 99. See xvfb-run(1).
 
37
#
 
38
# --server-args=
 
39
#   -ac disables host-based access control mechanisms. See Xserver(1).
 
40
#   -screen forces a screen configuration. At the time of writing
 
41
#      there is some disagreement between xvfb-run(1) and Xvfb(1)
 
42
#      about what the default is.
 
43
#
 
44
exec xvfb-run \
 
45
    --server-args="-ac -screen 0 1024x768x24" \
 
46
    --auto-servernum -- "$@"