-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxvfb
77 lines (66 loc) · 1.87 KB
/
xvfb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# Xvfb init script for Debian-based distros.
# Credit: https://www.exratione.com/2013/12/angularjs-headless-end-to-end-testing-with-protractor-and-selenium/
#
# The display number used must match the DISPLAY environment variable used
# for other applications that will use Xvfb. e.g. ':10'.
#
# Based on: https://gddithub.com/gmonfort/xvfb-init/blob/master/Xvfb
#
### BEGIN INIT INFO
# Provides: xvfb
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop custom Xvfb
# Description: Enable service provided by xvfb
### END INIT INFO
NAME=xvfb
DESC="$NAME - X Virtual Frame Buffer"
SCRIPTNAME=/etc/init.d/$NAME
XVFB=/usr/bin/Xvfb
PIDFILE=/var/run/${NAME}.pid
XVFB_ARGS=
set -e
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi
[ -x $XVFB ] || exit 0
# Load key functions to execute runlevel scripts.
. /lib/lsb/init-functions
[ -r /etc/default/Xvfb ] && . /etc/default/Xvfb
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE \
--background --make-pidfile --exec $XVFB -- $XVFB_ARGS ; then
log_end_msg 0
else
log_end_msg 1
fi
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --retry 5
if [ $? -eq 0 ] && [ -f $PIDFILE ]; then
/bin/rm -rf $PIDFILE
fi
log_end_msg $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
$0 stop && sleep 2 && $0 start
;;
status)
status_of_proc -p $PIDFILE $XVFB $NAME && exit 0 || exit $?
;;
*)
log_action_msg "Usage: ${SCRIPTNAME} {start|stop|status|restart|force-reload}"
exit 2
;;
esac
exit 0