Shell script to start xvfb
Below script can be used to start xvfb and manage the same.
#!/bin/sh
XVFB_DISPLAY=":1"
case "`uname`" in
"Linux")
XVFB_BINARY=/usr/X11R6/bin/Xvfb
;;
"SunOS"|"Solaris")
XVFB_BINARY=/usr/openwin/bin/Xsun
;;
*)
XVFB_BINARY=
;;
esac
if [ ! -z "$XVFB_BINARY" ]; then
case "$1" in
"start")
if [ -f "$XVFB_BINARY" ]; then
XVFB_PID="`pgrep -f "$XVFB_BINARY $XVFB_DISPLAY"`"
if [ -z "$XVFB_PID" ]; then
echo "xvfb: Starting Xvfb on $XVFB_DISPLAY"
`dirname $XVFB_BINARY`/Xvfb $XVFB_DISPLAY &
else
echo "xvfb: ERROR: Xvfb is running on $XVFB_DISPLAY"
exit
fi
else
echo "xvfb: ERROR: $XVFB_BINARY not found"
exit 1
fi
;;
"stop")
XVFB_PID="`pgrep -f "$XVFB_BINARY $XVFB_DISPLAY"`"
if [ ! -z "$XVFB_PID" ]; then
echo "xvfb: Stopping Xvfb on $XVFB_DISPLAY"
kill -9 $XVFB_PID
else
echo "xvfb: ERROR: Xvfb is not running on $XVFB_DISPLAY"
exit 1
fi
;;
"status")
XVFB_PID="`pgrep -f "$XVFB_BINARY $XVFB_DISPLAY"`"
if [ -z "$XVFB_PID" ]; then
echo "xvfb: Xvfb is not running on $XVFB_DISPLAY"
else
echo "xvfb: Xvfb is running on $XVFB_DISPLAY"
fi
;;
*)
echo " Usage: "
echo " $0 start (start Xvfb)"
echo " $0 stop (stop Xvfb)"
echo " $0 status (check if Xvfb is running)"
exit 1
;;
esac
else
echo "xvfb: ERROR: Could not determine platform"
exit 1
fi
exit 0
In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.