mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
moved pwrd to enterprise as it is an enterprise feature
Former-commit-id: bcb73644fb6d068ac44b1c8c6523467988db441e
This commit is contained in:
parent
9fdd46a823
commit
d922b7084c
@ -1,14 +0,0 @@
|
|||||||
instalar java
|
|
||||||
instalar selenium (descargar)
|
|
||||||
instalar xorg-x11-server-Xvfb
|
|
||||||
#wget ftp://rpmfind.net/linux/centos/6.6/os/x86_64/Packages/xorg-x11-server-Xvfb-1.15.0-22.el6.centos.x86_64.rpm
|
|
||||||
#yum install xorg-x11-server-Xvfb-1.15.0-22.el6.centos.x86_64.rpm
|
|
||||||
#Xvfb :99 -ac &
|
|
||||||
---> Pulsar Enter para continuar
|
|
||||||
#export DISPLAY=:99
|
|
||||||
#java -jar seleniumXXX.jar
|
|
||||||
|
|
||||||
Ya tenemos funcionando Selenium sin necesidad de X.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"capabilities": [
|
|
||||||
{
|
|
||||||
"browserName": "*firefox",
|
|
||||||
"maxInstances": 1,
|
|
||||||
"seleniumProtocol": "Selenium"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"browserName": "firefox",
|
|
||||||
"maxInstances": 1,
|
|
||||||
"seleniumProtocol": "WebDriver"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"configuration": {
|
|
||||||
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
|
|
||||||
"maxSession": 1,
|
|
||||||
"port": 5555,
|
|
||||||
"register": true,
|
|
||||||
"registerCycle": 5000
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
# Sample PWRD crontab control tweaks
|
|
||||||
|
|
||||||
# Do not allow firefox running for more than 1h
|
|
||||||
0 * * * * root /opt/pwrd_maintenance.sh -k
|
|
||||||
|
|
||||||
# Force node-start
|
|
||||||
*/5 * * * * root /opt/pwrd_maintenance.sh -s
|
|
||||||
|
|
||||||
# Reset firefox version if does not match required 47.0.1
|
|
||||||
* * * * * root /opt/pwrd_maintenance.sh -f
|
|
||||||
|
|
||||||
# Restart node if java process is not found
|
|
||||||
* * * * * root /opt/pwrd_maintenance.sh -r
|
|
||||||
|
|
||||||
# Restart node if no activity since last check
|
|
||||||
*/5 * * * * root /opt/pwrd_maintenance.sh -c1
|
|
||||||
|
|
||||||
# Restart node if connection have been lost to hub
|
|
||||||
*/5 * * * * root /opt/pwrd_maintenance.sh -c2
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Sample PWRD maintenance script
|
|
||||||
# **********************************************************************
|
|
||||||
|
|
||||||
# **********************************************************************
|
|
||||||
# Settings
|
|
||||||
hub_ip="192.168.1.10"
|
|
||||||
hub_port="4444"
|
|
||||||
|
|
||||||
# Customize PWR global installation directory
|
|
||||||
PWR_FIREFOX_INSTALLDIR="/opt"
|
|
||||||
|
|
||||||
# **********************************************************************
|
|
||||||
|
|
||||||
if [ "$1" == "-k" ]; then
|
|
||||||
killall --older-than 1h firefox >/dev/null 2>&1
|
|
||||||
|
|
||||||
elif [ "$1" == "-s" ]; then
|
|
||||||
/etc/init.d/pwrd start-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1
|
|
||||||
|
|
||||||
elif [ "$1" == "-f" ]; then
|
|
||||||
if [ "`firefox --version`" != "Mozilla Firefox 47.0.1" ]; then
|
|
||||||
$PWR_FIREFOX_INSTALLDIR/restore_firefox.sh >/dev/null 2>&1
|
|
||||||
echo `date +"%c"` Firefox restored > /tmp/restore_firefox.log
|
|
||||||
[`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1
|
|
||||||
[`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [ "$1" == "-r" ]; then
|
|
||||||
if [ ` ps aux | grep "java -jar" | grep -v grep | wc -l` -lt 1 ]; then
|
|
||||||
[`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1
|
|
||||||
[`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1
|
|
||||||
echo `date +"%c"` PWRD restarted, java process not found > /tmp/pwrd_restart_detected.log
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [ "$1" == "-c1" ]; then
|
|
||||||
if [ $(/etc/pandora/plugins/grep_log /var/log/pwr/pwr_std.log check_pwrd ".*" | wc -l) -eq 0 ]; then
|
|
||||||
[`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1
|
|
||||||
[`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1
|
|
||||||
echo $(date +"%c") PWRD restarted, no output detected in log > /tmp/pwrd_restart_detected.log
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [ "$1" == "-c2" ]; then
|
|
||||||
if [ $(/etc/pandora/plugins/grep_log /var/log/pwr/pwr_std.log check_pwrd_err_conn "refused" | grep "$hub_ip:$hub_port [/$hub_ip] failed:" | wc -l) -gt 0 ]; then
|
|
||||||
/etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1
|
|
||||||
echo $(date +"%c") PWRD restarted, lost connection with hub > /tmp/pwrd_restart_detected.log
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Script to restore firefox to tar
|
|
||||||
#
|
|
||||||
# **********************************************************************
|
|
||||||
|
|
||||||
# Customize PWR global installation directory
|
|
||||||
PWR_FIREFOX_INSTALLDIR="/opt"
|
|
||||||
|
|
||||||
cd $PWR_FIREFOX_INSTALLDIR
|
|
||||||
|
|
||||||
if [ -f firefox-47.0.1.tar ]; then
|
|
||||||
rm -rf firefox-47 >/dev/null 2>&1
|
|
||||||
mv firefox firefox_ >/dev/null 2>&1
|
|
||||||
tar xvf firefox-47.0.1.tar >/dev/null 2>&1
|
|
||||||
mv firefox firefox-47 >/dev/null 2>&1
|
|
||||||
mv firefox_ firefox >/dev/null 2>&1
|
|
||||||
else
|
|
||||||
echo "firefox-47.0.1.tar not found, please leave a copy at $PWR_FIREFOX_INSTALLDIR"
|
|
||||||
fi
|
|
@ -1 +0,0 @@
|
|||||||
4881ba55982d75040775bafdffcdf57b2cd7ea13
|
|
Binary file not shown.
@ -1,150 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
HELP=`cat<<_HELP
|
|
||||||
**********************
|
|
||||||
PWR Server installer
|
|
||||||
**********************
|
|
||||||
|
|
||||||
To install the Pandora web robot daemon (pwrd)
|
|
||||||
Please launch this script as root:
|
|
||||||
|
|
||||||
$0 --install [[user] [directory]]
|
|
||||||
|
|
||||||
|
|
||||||
_HELP
|
|
||||||
`
|
|
||||||
|
|
||||||
if [ "$1" == "" ] || [ "$1" != "--install" ]; then
|
|
||||||
echo "$HELP"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "`which rpm`" ]; then
|
|
||||||
if [ "`rpm -qa | grep xorg-x11-server-Xvfb | wc -l`" == "0" ]; then
|
|
||||||
echo "Package xorg-x11-server-Xvfb is required"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Xvfb is required, please confirm is installed in your system"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# default user is running user
|
|
||||||
GLOBAL_INST_USER=`whoami`
|
|
||||||
|
|
||||||
if [ "$2" != "" ]; then
|
|
||||||
if [ `cat /etc/passwd | cut -f1 -d':' | grep -w "$2" | wc -l` -gt 0 ]; then
|
|
||||||
GLOBAL_INST_USER=$2
|
|
||||||
elif [ -d "$2" ]; then
|
|
||||||
GLOBAL_INST_DIR=$2
|
|
||||||
else
|
|
||||||
echo "Cannot use \"$2\" as user nor directory"
|
|
||||||
echo "$HELP"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$3" != "" ]; then
|
|
||||||
if [ -d "$3" ]; then
|
|
||||||
GLOBAL_INST_DIR=$3
|
|
||||||
elif [ `cat /etc/passwd | cut -f1 -d':' | grep -w "$3" | wc -l` -gt 0 ]; then
|
|
||||||
GLOBAL_INST_USER=$3
|
|
||||||
else
|
|
||||||
echo "Cannot use \"$3\" as directory nor user"
|
|
||||||
echo "$HELP"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod +x pwrd
|
|
||||||
|
|
||||||
PWR_SERVER_DEST=$GLOBAL_INST_DIR/usr/lib/pwr
|
|
||||||
PWR_SERVER_RSC=$GLOBAL_INST_DIR/etc/pwr/tmp
|
|
||||||
PWR_SERVER_LOG=$GLOBAL_INST_DIR/var/log/pwr
|
|
||||||
PWR_FIREFOX_INSTALLDIR=$GLOBAL_INST_DIR/opt
|
|
||||||
|
|
||||||
PWR_FIREFOX_INSTALLDIR_ESCAPED=`echo $PWR_FIREFOX_INSTALLDIR | sed 's/\\//\\\\\//g'`
|
|
||||||
GLOBAL_INST_DIR_ESCAPED=`echo $GLOBAL_INST_DIR | sed 's/\\//\\\\\//g'`
|
|
||||||
|
|
||||||
[ -d $PWR_SERVER_DEST ] || mkdir -p $PWR_SERVER_DEST
|
|
||||||
[ -d $PWR_SERVER_LOG ] || mkdir -p $PWR_SERVER_LOG
|
|
||||||
[ -d $PWR_SERVER_RSC ] || mkdir -p $PWR_SERVER_RSC
|
|
||||||
[ -d $PWR_FIREFOX_INSTALLDIR ] || mkdir -p $PWR_FIREFOX_INSTALLDIR
|
|
||||||
[ -d $GLOBAL_INST_DIR/etc/init.d ] || mkdir -p $GLOBAL_INST_DIR/etc/init.d
|
|
||||||
|
|
||||||
tar xvf firefox-47.0.1.tar >/dev/null
|
|
||||||
mv firefox $PWR_FIREFOX_INSTALLDIR/firefox-47
|
|
||||||
ln -s $PWR_FIREFOX_INSTALLDIR/firefox-47/firefox $PWR_FIREFOX_INSTALLDIR/firefox
|
|
||||||
|
|
||||||
tar xvzf firefox_profile.tar.gz >/dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to deploy firefox profile, please retry installation"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
chown -R "$GLOBAL_INST_USER". firefox_profile
|
|
||||||
[ ! -d "$PWR_FIREFOX_INSTALLDIR/firefox_profile" ] && mv firefox_profile $PWR_FIREFOX_INSTALLDIR
|
|
||||||
|
|
||||||
[ -d "$PWR_FIREFOX_INSTALLDIR/selenium" ] || mkdir -p $PWR_FIREFOX_INSTALLDIR/selenium
|
|
||||||
|
|
||||||
cp config.json $PWR_FIREFOX_INSTALLDIR/selenium/
|
|
||||||
|
|
||||||
ln -s $PWR_FIREFOX_INSTALLDIR/firefox /usr/bin/firefox
|
|
||||||
|
|
||||||
# Generate logrotate configuration
|
|
||||||
echo <<EO_LROTATE > /etc/logrotate.d/pwrd
|
|
||||||
/var/log/pwr/pwr_std.log
|
|
||||||
/var/log/pwr/xvfb.log
|
|
||||||
/var/log/pwr/pwr_error.log {
|
|
||||||
weekly
|
|
||||||
missingok
|
|
||||||
size 300000
|
|
||||||
rotate 3
|
|
||||||
maxage 90
|
|
||||||
compress
|
|
||||||
notifempty
|
|
||||||
copytruncate
|
|
||||||
}
|
|
||||||
|
|
||||||
EO_LROTATE
|
|
||||||
|
|
||||||
cp ./extras/restore_firefox.sh $PWR_FIREFOX_INSTALLDIR/
|
|
||||||
cp ./extras/pwrd_maintenance.sh $PWR_FIREFOX_INSTALLDIR/
|
|
||||||
cp ./selenium-server-standalone-2.53.1.jar $PWR_SERVER_DEST/
|
|
||||||
cp ./pwrd /etc/init.d/pwrd
|
|
||||||
cp ./pwrd $GLOBAL_INST_DIR/etc/init.d/pwrd
|
|
||||||
chmod +x /etc/init.d/pwrd
|
|
||||||
|
|
||||||
# Update pwrd daemon
|
|
||||||
if [ "$GLOBAL_INST_DIR" != "" ]; then
|
|
||||||
echo "Adjusting pwrd global directory to: $GLOBAL_INST_DIR"
|
|
||||||
sed -i "s/PWR_GLOBAL_DIR=\"\"/PWR_GLOBAL_DIR=\"$GLOBAL_INST_DIR_ESCAPED\"/g" /etc/init.d/pwrd
|
|
||||||
sed -i "s/PWR_GLOBAL_DIR=\"\"/PWR_GLOBAL_DIR=\"$GLOBAL_INST_DIR_ESCAPED\"/g" $GLOBAL_INST_DIR/etc/init.d/pwrd
|
|
||||||
echo "Adjusting pwrd_maintenance global directory to: $PWR_FIREFOX_INSTALLDIR"
|
|
||||||
sed -i "s/PWR_FIREFOX_INSTALLDIR=\"\/opt\"/PWR_FIREFOX_INSTALLDIR=\"$PWR_FIREFOX_INSTALLDIR_ESCAPED\"/g" $PWR_FIREFOX_INSTALLDIR/pwrd_maintenance.sh
|
|
||||||
echo "Adjusting restore_firefox global directory to: $PWR_FIREFOX_INSTALLDIR"
|
|
||||||
sed -i "s/PWR_FIREFOX_INSTALLDIR=\"\/opt\"/PWR_FIREFOX_INSTALLDIR=\"$PWR_FIREFOX_INSTALLDIR_ESCAPED\"/g" $PWR_FIREFOX_INSTALLDIR/restore_firefox.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$GLOBAL_INST_USER" != "" ]; then
|
|
||||||
echo "Adjusting pwrd global user to: $GLOBAL_INST_USER"
|
|
||||||
sed -i "s/USER=\"root\"/USER=\"$GLOBAL_INST_USER\"/g" /etc/init.d/pwrd
|
|
||||||
sed -i "s/USER=\"root\"/USER=\"$GLOBAL_INST_USER\"/g" $GLOBAL_INST_DIR/etc/init.d/pwrd
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_DEST
|
|
||||||
[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_LOG
|
|
||||||
[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_RSC
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
*********************
|
|
||||||
PWR Server deployed
|
|
||||||
*********************
|
|
||||||
|
|
||||||
Succesfully installed!
|
|
||||||
|
|
||||||
Now you can start the service with:
|
|
||||||
|
|
||||||
/etc/init.d/pwrd start
|
|
||||||
|
|
||||||
|
|
||||||
EOF
|
|
@ -1,392 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# **********************************************************************
|
|
||||||
# Pandora FMS PWR Server Daemon
|
|
||||||
# (c) 2008-2018 Artica ST
|
|
||||||
#
|
|
||||||
# Please see http://www.pandorafms.org
|
|
||||||
# **********************************************************************
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: pwrd
|
|
||||||
# Required-Start: $network
|
|
||||||
# Required-Stop: $network
|
|
||||||
# Default-Start: 2 3 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: Startup script daemon for PWR server
|
|
||||||
# Description: Startup script daemon for PWR server (linux)
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
# chkconfig: - 85 1
|
|
||||||
# description: PWRD Grid is a distributed platform for browser-based automation.
|
|
||||||
# processname: pwr
|
|
||||||
|
|
||||||
# Source function library.
|
|
||||||
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
. /etc/rc.d/init.d/functions
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# **********************************************************************
|
|
||||||
# Configuration options
|
|
||||||
# Example node capabilities: -browser browserName=firefox,maxInstances=1,platform=LINUX
|
|
||||||
|
|
||||||
# Customize Java binary path
|
|
||||||
JAVA=/usr/bin/java
|
|
||||||
|
|
||||||
# Customize PWR global installation directory
|
|
||||||
PWR_GLOBAL_DIR=""
|
|
||||||
|
|
||||||
# Customize PWR running user
|
|
||||||
USER="root"
|
|
||||||
|
|
||||||
# Customize PWR application files directory
|
|
||||||
PWR_INST_DIR="$PWR_GLOBAL_DIR/opt"
|
|
||||||
|
|
||||||
# Customize port for PWR
|
|
||||||
PWR_PORT=4444
|
|
||||||
PWR_HUB_PORT=4444
|
|
||||||
PWR_NODE_PORT=5555
|
|
||||||
|
|
||||||
# Extra options for PWR
|
|
||||||
PWR_OPTS=" -firefoxProfileTemplate $PWR_INST_DIR/firefox_profile "
|
|
||||||
PWR_NODE_OPTS=" -nodeConfig $PWR_INST_DIR/selenium/config.json "
|
|
||||||
PWR_HUB_OPTS=""
|
|
||||||
|
|
||||||
|
|
||||||
# **********************************************************************
|
|
||||||
# Default paths
|
|
||||||
|
|
||||||
PWR_DIR="$PWR_GLOBAL_DIR/usr/lib/pwr"
|
|
||||||
LOG_DIR="$PWR_GLOBAL_DIR/var/log/pwr"
|
|
||||||
STD_LOG="$LOG_DIR/pwr_std.log"
|
|
||||||
BASE_DIR="$PWR_GLOBAL_DIR/etc/pwr/tmp"
|
|
||||||
PWR="$PWR_DIR/selenium-server-standalone-2.53.1.jar"
|
|
||||||
XVFB_PID_FILE="$BASE_DIR/xvfb.pid"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# **********************************************************************
|
|
||||||
# Variables
|
|
||||||
|
|
||||||
host=`ip a show $(route -n | awk '/^0\.0\.0\.0/ {print $NF}') | grep "inet " | awk '{print $2}' | cut -f1 -d'/' | head -1`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# **********************************************************************
|
|
||||||
# Functions
|
|
||||||
|
|
||||||
# Start Xvfb, required for firefox in server without X
|
|
||||||
function start_xvfb() {
|
|
||||||
`which Xvfb >/dev/null 2>&1`
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Xvfb not found, please install it"
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
failure
|
|
||||||
echo 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
Xvfb :99 -screen 0 1400x768x24 -ac +extension RANDR > $LOG_DIR/xvfb.log 2>&1 & echo $! > $XVFB_PID_FILE
|
|
||||||
export DISPLAY=:99
|
|
||||||
echo 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Stop Xvfb
|
|
||||||
function stop_xvfb() {
|
|
||||||
echo
|
|
||||||
if test -f $XVFB_PID_FILE ; then
|
|
||||||
# Check if there's more instances of pwrd running i.e. standalone + node
|
|
||||||
if [ ! -e "$BASE_DIR/pwrd_node.pid" ] && [ ! -e "$BASE_DIR/pwrd.pid" ]; then
|
|
||||||
if [ ! -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
echo -n "Stopping Xvfb..."
|
|
||||||
fi
|
|
||||||
PID=$(cat $XVFB_PID_FILE)
|
|
||||||
if [ "$PID" != "" ] && [ `kill -9 $PID 2>&1 | grep "No such process" | wc -l` == "1" ]; then
|
|
||||||
# PID file exists but no process
|
|
||||||
[ -f $XVFB_PID_FILE ] && rm -f $XVFB_PID_FILE
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
success
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
[ -e $BASE_DIR/pwrd_node.pid ] && echo -n `cat $BASE_DIR/pwrd_node.pid`
|
|
||||||
[ -e $BASE_DIR/pwrd.pid ] && echo -n `cat $BASE_DIR/pwrd.pid`
|
|
||||||
echo -e "\nThere're pwrd processes left. Skipping Xvfb"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# START
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
# Start Selenium Standalone server
|
|
||||||
function start() {
|
|
||||||
if test -f $pid_file; then
|
|
||||||
PID=`cat $pid_file`
|
|
||||||
if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then
|
|
||||||
echo "PWRD is already running: $PID"
|
|
||||||
exit 2
|
|
||||||
else
|
|
||||||
echo "Removing stale pid file: $pid_file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "`start_xvfb`" != "0" ]; then
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
failure
|
|
||||||
fi
|
|
||||||
echo "Failed... Check Xvfb"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
echo -n "Starting PWRD..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
export DISPLAY=:99
|
|
||||||
PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_PORT $PWR_OPTS > $STD_LOG 2>&1 & echo \$!")
|
|
||||||
if [ $? == "0" ]; then
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
success
|
|
||||||
fi
|
|
||||||
echo "Success"
|
|
||||||
else
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
failure
|
|
||||||
fi
|
|
||||||
echo "Failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Store PID
|
|
||||||
echo -n $PID > $pid_file
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Start Selenium GRID server: HUB component
|
|
||||||
function start-hub() {
|
|
||||||
if test -f $pid_file; then
|
|
||||||
PID=`cat $pid_file`
|
|
||||||
if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then
|
|
||||||
echo "PWRD is already running: $PID"
|
|
||||||
exit 2
|
|
||||||
else
|
|
||||||
echo "Removing stale pid file: $pid_file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
echo -n "Starting PWRD..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# No Xvfb needed in hub mode
|
|
||||||
|
|
||||||
PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_HUB_PORT -role hub $PWR_HUB_OPTS > $STD_LOG 2>&1 & echo \$!")
|
|
||||||
if [ $? == "0" ]; then
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
success
|
|
||||||
fi
|
|
||||||
echo "Success"
|
|
||||||
else
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
failure
|
|
||||||
fi
|
|
||||||
echo "Failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Store PID
|
|
||||||
echo -n $PID > $pid_file
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo -e "Add nodes to HUB executing:\n $0 start-node http://$host:$PWR_HUB_PORT/grid/register"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Start Selenium GRID server: Node Connect to hub
|
|
||||||
function start-node() {
|
|
||||||
if test -f $pid_file ; then
|
|
||||||
PID=`cat $pid_file`
|
|
||||||
if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then
|
|
||||||
echo "PWRD is already running: $PID"
|
|
||||||
exit 2
|
|
||||||
else
|
|
||||||
echo "Removing stale pid file: $pid_file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "`start_xvfb`" != "0" ]; then
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
failure
|
|
||||||
fi
|
|
||||||
echo "Failed... Check Xvfb"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
echo -n "Starting PWRD..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
export DISPLAY=:99
|
|
||||||
PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_NODE_PORT -role node -hub $1 $PWR_OPTS > $STD_LOG 2>&1 & echo \$!")
|
|
||||||
if [ $? == "0" ]; then
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
success
|
|
||||||
fi
|
|
||||||
echo "Success"
|
|
||||||
else
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
failure
|
|
||||||
fi
|
|
||||||
echo "Failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Store PID
|
|
||||||
echo -n $PID > $pid_file
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# STOP
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
# Stop Selenium Standalone server
|
|
||||||
function stop() {
|
|
||||||
if test -f $pid_file ; then
|
|
||||||
echo -n "Stopping PWRD..."
|
|
||||||
PID=$(cat $pid_file)
|
|
||||||
[ "$PID" == "" ] && PID=`ps aux | grep "$JAVA -jar $PWR" | grep -v grep | awk '{print $2}'`
|
|
||||||
[ "$PID" != "" ] && ps --pid $PID >/dev/null && su $USER -c "kill -3 $PID"
|
|
||||||
[ "$PID" != "" ] && ps --pid $PID >/dev/null && kill -9 $PID >/dev/null 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
sleep 2
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
success
|
|
||||||
fi
|
|
||||||
test -f $pid_file && rm -f $pid_file
|
|
||||||
|
|
||||||
stop_xvfb
|
|
||||||
else
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
failure
|
|
||||||
else
|
|
||||||
echo "Failed"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Clean pid file
|
|
||||||
test -f $pid_file && rm -f $pid_file
|
|
||||||
else
|
|
||||||
echo "PWRD is not running."
|
|
||||||
stop_xvfb
|
|
||||||
if [ -e /etc/rc.d/init.d/functions ]; then
|
|
||||||
success
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# STATUS
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
# Status of Selenium Standalone server
|
|
||||||
function status() {
|
|
||||||
mode=$1
|
|
||||||
if test -f $pid_file ; then
|
|
||||||
echo "checking: $pid_file"
|
|
||||||
PID=`cat $pid_file`
|
|
||||||
if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then
|
|
||||||
echo "PWRD$mode is running: $PID"
|
|
||||||
if test -f $XVFB_PID_FILE ; then
|
|
||||||
PID=`cat $XVFB_PID_FILE`
|
|
||||||
if test -f $XVFB_PID_FILE ; then
|
|
||||||
echo "Xvfb is running: $PID"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "PWRD$mode isn't running..."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "PWRD$mode isn't running..."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# MAIN
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
if [ ! -x "$JAVA" ]; then
|
|
||||||
echo "Please verify $JAVA is a valid java" 2>&1
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start) # Standalone
|
|
||||||
pid_file=$BASE_DIR/pwrd.pid
|
|
||||||
start
|
|
||||||
;;
|
|
||||||
start-hub) # hub
|
|
||||||
pid_file=$BASE_DIR/pwrd_hub.pid
|
|
||||||
start-hub
|
|
||||||
;;
|
|
||||||
start-node) # node
|
|
||||||
pid_file=$BASE_DIR/pwrd_node.pid
|
|
||||||
start-node $2
|
|
||||||
;;
|
|
||||||
stop) # standalone
|
|
||||||
pid_file=$BASE_DIR/pwrd.pid
|
|
||||||
stop
|
|
||||||
;;
|
|
||||||
stop-hub) # hub
|
|
||||||
pid_file=$BASE_DIR/pwrd_hub.pid
|
|
||||||
stop
|
|
||||||
;;
|
|
||||||
stop-node) # node
|
|
||||||
pid_file=$BASE_DIR/pwrd_node.pid
|
|
||||||
stop
|
|
||||||
;;
|
|
||||||
restart) # standalone
|
|
||||||
pid_file=$BASE_DIR/pwrd.pid
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
;;
|
|
||||||
restart-hub) # hub
|
|
||||||
pid_file=$BASE_DIR/pwrd_hub.pid
|
|
||||||
stop
|
|
||||||
start-hub
|
|
||||||
;;
|
|
||||||
restart-node) # node
|
|
||||||
pid_file=$BASE_DIR/pwrd_node.pid
|
|
||||||
stop
|
|
||||||
start-node $2
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
pid_file=$BASE_DIR/pwrd.pid
|
|
||||||
status ""
|
|
||||||
pid_file=$BASE_DIR/pwrd_hub.pid
|
|
||||||
status " HUB"
|
|
||||||
pid_file=$BASE_DIR/pwrd_node.pid
|
|
||||||
status " Node"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $SELF start*|stop*|restart*|status"
|
|
||||||
echo " start* (standalone, hub or node)"
|
|
||||||
echo " start"
|
|
||||||
echo " start-hub"
|
|
||||||
echo " start-node http://hub:4444/grid/register"
|
|
||||||
echo " stop* (standalone, hub or node)"
|
|
||||||
echo " stop"
|
|
||||||
echo " stop-hub"
|
|
||||||
echo " stop-node"
|
|
||||||
echo " restart* (standalone, hub or node)"
|
|
||||||
echo " restart"
|
|
||||||
echo " restart-hub"
|
|
||||||
echo " restart-node http://hub:4444/grid/register"
|
|
||||||
exit 9
|
|
||||||
;;
|
|
||||||
esac
|
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user