Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 95 lines (83 sloc) 2.12 KB
#!/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 $?