2014-08-30 18:45:08 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
XPID=
|
|
|
|
function create_fake_x ( )
|
|
|
|
{
|
2014-08-30 18:53:35 +00:00
|
|
|
export DISPLAY=":$1"
|
2014-08-30 18:45:08 +00:00
|
|
|
echo "Starting fake X: ${DISPLAY}"
|
|
|
|
Xvfb ${DISPLAY} &
|
|
|
|
XPID=$!
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function destroy_fake_x ( )
|
|
|
|
{
|
|
|
|
if [ -n "${XPID}" ]
|
|
|
|
then
|
|
|
|
echo "Stopping fake X: ${XPID}"
|
|
|
|
kill ${XPID}
|
|
|
|
wait ${XPID}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -n "$3" ]
|
|
|
|
then
|
2014-08-30 18:53:35 +00:00
|
|
|
export PATH=$3:$PATH
|
2014-08-30 18:45:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
create_fake_x "$1"
|
2014-11-06 20:03:13 +00:00
|
|
|
if [ -n "$4" ]
|
|
|
|
then
|
|
|
|
xrdb -load "$4"
|
|
|
|
fi
|
2014-08-30 18:53:35 +00:00
|
|
|
echo "$DISPLAY"
|
2014-08-30 18:45:08 +00:00
|
|
|
$2
|
|
|
|
RES=$?
|
|
|
|
|
|
|
|
destroy_fake_x
|
|
|
|
|
|
|
|
exit ${RES}
|