2014-08-30 14:45:08 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
XPID=
|
2016-01-05 10:46:43 -05:00
|
|
|
FPID=
|
2021-08-14 07:03:16 -04:00
|
|
|
create_fake_x()
|
2014-08-30 14:45:08 -04:00
|
|
|
{
|
2014-08-30 14:53:35 -04:00
|
|
|
export DISPLAY=":$1"
|
2017-07-27 11:30:39 -04:00
|
|
|
echo -n "Starting fake X for display ${DISPLAY}: "
|
2021-08-14 07:03:16 -04:00
|
|
|
Xvfb -nolisten tcp +extension XINERAMA +xinerama -screen 0 1280x1024x24 "${DISPLAY}" &>$2-server.log &
|
2014-08-30 14:45:08 -04:00
|
|
|
XPID=$!
|
2017-07-27 11:30:39 -04:00
|
|
|
echo "pid ${XPID}"
|
2021-08-14 07:03:16 -04:00
|
|
|
sleep 1
|
2017-05-30 09:07:48 -04:00
|
|
|
if [ -x "$(which fluxbox 2>/dev/null)" ]; then
|
2017-07-27 11:30:39 -04:00
|
|
|
echo -n "Starting fluxbox for display ${DISPLAY}: "
|
|
|
|
timeout -k 30s 30s fluxbox &>$2-fluxbox.log &
|
2017-05-30 09:07:48 -04:00
|
|
|
FPID=$!
|
2017-07-27 11:30:39 -04:00
|
|
|
echo "pid ${FPID}"
|
2017-05-30 09:07:48 -04:00
|
|
|
sleep 1
|
|
|
|
fi
|
2014-08-30 14:45:08 -04:00
|
|
|
}
|
|
|
|
|
2021-08-14 07:03:16 -04:00
|
|
|
destroy_fake_x()
|
2014-08-30 14:45:08 -04:00
|
|
|
{
|
|
|
|
if [ -n "${XPID}" ]
|
|
|
|
then
|
2017-05-30 09:07:48 -04:00
|
|
|
if [ -n "${FPID}" ]; then
|
2017-07-27 11:30:39 -04:00
|
|
|
echo -n "Stopping fluxbox for display ${DISPLAY} (pid ${FPID}): "
|
2021-08-14 07:03:16 -04:00
|
|
|
if kill "${FPID}" &>$1-kill-fluxbox.log; then
|
2017-07-27 11:30:39 -04:00
|
|
|
echo -n " killed... "
|
2021-08-14 07:03:16 -04:00
|
|
|
wait "${FPID}" &>$1-wait-fluxbox.log
|
2017-07-27 11:30:39 -04:00
|
|
|
echo "stopped"
|
|
|
|
else
|
|
|
|
echo -n " failed to kill"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo -n "Stopping fake X for display ${DISPLAY} (pid ${XPID}): "
|
2021-08-14 07:03:16 -04:00
|
|
|
if kill "${XPID}" &>$1-kill-X.log; then
|
2017-07-27 11:30:39 -04:00
|
|
|
echo -n " killed... "
|
2021-08-14 07:03:16 -04:00
|
|
|
wait "${XPID}" &>$1-wait-X.log
|
2017-07-27 11:30:39 -04:00
|
|
|
echo "stopped"
|
|
|
|
else
|
|
|
|
echo -n " failed to kill"
|
2017-05-30 09:07:48 -04:00
|
|
|
fi
|
2014-08-30 14:45:08 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-07-27 11:30:39 -04:00
|
|
|
if [ -n "$4" ]
|
2014-08-30 14:45:08 -04:00
|
|
|
then
|
2017-07-27 11:30:39 -04:00
|
|
|
export PATH=$4:$PATH
|
2014-08-30 14:45:08 -04:00
|
|
|
fi
|
|
|
|
|
2017-07-27 11:30:39 -04:00
|
|
|
create_fake_x "$1" "$2"
|
|
|
|
"$3" "$5" &> "$2-test.log"
|
2014-08-30 14:45:08 -04:00
|
|
|
RES=$?
|
|
|
|
|
2017-07-27 11:30:39 -04:00
|
|
|
destroy_fake_x "$2"
|
2014-08-30 14:45:08 -04:00
|
|
|
|
2021-08-14 07:03:16 -04:00
|
|
|
exit "${RES}"
|