Skip to content

Commit

Permalink
add class selenium::config
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Oct 1, 2013
1 parent 69e8010 commit dcf5ebf
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 0 deletions.
31 changes: 31 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# == Class: selenium::config
#
# This class should be considered private.
#
#
# === Parameters
#
# Accepts no parameters.
#
#
# === Examples
#
# class{ 'selenium::config': }
#
#
# === Authors
#
# Joshua Hoblitt <[email protected]>
#
#
class selenium::config inherits selenium::server {

file { '/etc/init.d/selenium':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0755',
content => template("${module_name}/init.d/selenium.erb"),
}

}
16 changes: 16 additions & 0 deletions spec/classes/selenium_config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper'

describe 'selenium::config' do
let(:title) { 'redhat' }
let(:facts) {{ :osfamily=> 'RedHat' }}

it do
should contain_file('/etc/init.d/selenium').with({
'ensure' => 'file',
'owner' => 'root',
'group' => 'root',
'mode' => '0755',
}).with_content(/selenium-server-standalone/)
end

end
123 changes: 123 additions & 0 deletions templates/init.d/selenium.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/sh
#
# selenium <summary>
#
# chkconfig: 2345 99 99
#
# description: <description, split multiple lines with \
# a backslash>

### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description:
# Description:
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

#SLNM_DISPLAY=:<%= scope.lookupvar('display::display') %>
SLNM_DISPLAY=:0
#SLNM_USER=<%= @user %>
SLNM_USER='selenium'
SLNM_LOG='/opt/selenium/log/server.log'
SLNM_ERROR_LOG='/opt/selenium/log/error.log'
SLNM_JAR='/opt/selenium/jars/selenium-server-standalone-2.35.0.jar'
SLNM_OPTIONS='-Dwebdriver.enable.native.events=1'

prog="selenium"
#config="<path to major config file>"

#[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog
pidfile=/var/run/${prog}.pid

# pidfile must be owned by selenium user
exec="DISPLAY=${SLNM_DISPLAY} java -jar ${SLNM_JAR} ${SLNM_OPTIONS} > ${SLNM_LOG} 2> ${SLNM_ERROR_LOG} & "'echo $!'" > ${pidfile}"

start() {
# [ -x $exec ] || exit 5
# [ -f $config ] || exit 6
# pidfile must be owned by selenium user
touch $pidfile
chown $SLNM_USER $pidfile
echo -n $"Starting $prog: "
# if not running, start it up here, usually something like "daemon $exec"
daemon --pidfile=${pidfile} --user=${SLNM_USER} ${exec}
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
stop
start
}

reload() {
restart
}

force_reload() {
restart
}

rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}


case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?

0 comments on commit dcf5ebf

Please sign in to comment.