Skip to content

Instantly share code, notes, and snippets.

@jparrill
Created May 12, 2014 07:22
Show Gist options
  • Save jparrill/2e003ccf4d404990cfdf to your computer and use it in GitHub Desktop.
Save jparrill/2e003ccf4d404990cfdf to your computer and use it in GitHub Desktop.
Init Script for Xvfb
#!/bin/bash
#
# /etc/rc.d/init.d/xvfb
#
# chkconfig: 345 95 28
# description: Starts/Stops X Virtual Framebuffer server
# processname: Xvfb
#
. /etc/init.d/functions
[ "${NETWORKING}" = "no" ] && exit 0
PROG="/usr/bin/Xvfb"
PROG_OPTIONS=":20 -ac -screen 0 1024x768x24"
PROG_OUTPUT="/tmp/Xvfb.out"
USER="develenv"
case "$1" in
start)
echo -n "Starting : X Virtual Frame Buffer "
su - $USER -c "$PROG $PROG_OPTIONS">>$PROG_OUTPUT 2>&1 &
disown -ar
/bin/usleep 500000
status Xvfb & >/dev/null && echo_success || echo_failure
RETVAL=$?
export DISPLAY=localhost:20.0
if [ $RETVAL -eq 0 ]; then
/bin/touch /var/lock/subsys/Xvfb
/sbin/pidof -o %PPID -x Xvfb > /var/run/Xvfb.pid
fi
echo
;;
stop)
echo -n "Shutting down : X Virtual Frame Buffer"
killproc $PROG
RETVAL=$?
[ $RETVAL -eq 0 ] && /bin/rm -f /var/lock/subsys/Xvfb
/var/run/Xvfb.pid
echo
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
status)
status Xvfb
RETVAL=$?
;;
*)
echo $"Usage: $0 (start|stop|restart|reload|status)"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment