-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathselenium-headless
executable file
·94 lines (83 loc) · 2.12 KB
/
selenium-headless
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
### BEGIN INIT INFO
# Provides: selenium-headless
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/Stop a Selenium-RC headless environment including Xvfb
### END INIT INFO
# License: https://github.com/amenk/SelfScripts/blob/master/LICENSE.md
#
# BETA-VERSION
# Fixmes:
# - We should take care of running the environment under a non-priviledged user
#
#
# Installation:
# you have to create an /etc/selenium-headless.conf containing something like that:
#LOG=/var/log/selenium.log
#DEBUGLOG=/var/log/selenium-debug.log
#SELENIUM_JAR=/opt/selenium-server-standalone.jar
#FIREFOX_TEMPLATE=/home/myuser/.mozilla/firefox/abcdefg.selenium/
#
# Source function library.
. /lib/lsb/init-functions
# Source config
. /etc/selenium-headless.conf
DISPLAY_NO=99
JAVA=/usr/bin/java
XVFB=/usr/bin/Xvfb
NOHUP=/usr/bin/nohup
SELENIUMPIDFILE=/var/run/Selenium-RC.pid
start() {
log_daemon_msg "Starting Xvfb"
daemon --dbglog=$LOG --errlog=$LOG --stdout=$LOG --stderr=$LOG\
--name Xvfb -- $XVFB :$DISPLAY_NO -ac -screen 0 1024x768x8
log_end_msg $?
log_daemon_msg "Starting Selenium RC"
if [ -n "$DEBUGLOG" ]; then
DBG="-log $DEBUGLOG -browserSideLog "
else
DBG=""
fi
daemon --dbglog=$LOG --errlog=$LOG --stdout=$LOG --stderr=$LOG\
--name Selenium-RC -i --env=DISPLAY=$DISPLAY_NO\
-- $JAVA -jar $SELENIUM_JAR $DBG-firefoxProfileTemplate $FIREFOX_TEMPLATE
log_end_msg $?
return
}
stop() {
log_daemon_msg "Stopping Selenium RC"
daemon --stop --name Selenium-RC
log_end_msg $?
log_daemon_msg "Stopping Xvfb"
daemon --stop --name Xvfb
log_end_msg $?
return
}
status() {
daemon -v10 --running --name Xvfb
daemon -v10 --running --name Selenium-RC
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: {start|stop|status|restart"
exit 1
;;
esac
exit $?