Fixed support for Solaris 10

This commit is contained in:
Louwrentius 2010-03-26 22:12:12 +00:00
parent efd6f72a5e
commit bdaab0afe3
2 changed files with 39 additions and 9 deletions

46
ppss
View File

@ -25,7 +25,7 @@ trap 'kill_process' SIGINT
# Setting some vars. # Setting some vars.
SCRIPT_NAME="Distributed Parallel Processing Shell Script" SCRIPT_NAME="Distributed Parallel Processing Shell Script"
SCRIPT_VERSION="2.60" SCRIPT_VERSION="2.61"
# The first argument to this script can be a mode. # The first argument to this script can be a mode.
MODES="node start config stop pause continue deploy status erase kill ec2" MODES="node start config stop pause continue deploy status erase kill ec2"
@ -45,6 +45,21 @@ then
PPSS_DIR="ppss_dir" PPSS_DIR="ppss_dir"
fi fi
get_time_in_seconds () {
if [ "$ARCH" == "SunOS" ]
then
#
# Dirty hack because this ancient operating system does not support +%s...
#
THE_TIME=`truss /usr/bin/date 2>&1 | grep ^time | awk '{ print $3 }'`
else
THE_TIME="$(date +%s)"
fi
echo "$THE_TIME"
}
CONFIG="" CONFIG=""
HOSTNAME="`hostname`" HOSTNAME="`hostname`"
ARCH="`uname`" ARCH="`uname`"
@ -69,7 +84,7 @@ PROCESSORS=""
STOP_KEY="$RANDOM$RANDOM$RANDOM" # This is a signal to the listener to stop. STOP_KEY="$RANDOM$RANDOM$RANDOM" # This is a signal to the listener to stop.
KILL_KEY="$RANDOM$RANDOM$RANDOM" # This is a signal to stop immediately and kill KILL_KEY="$RANDOM$RANDOM$RANDOM" # This is a signal to stop immediately and kill
RECURSION="1" # all running processes. RECURSION="1" # all running processes.
START_PPSS="$(date +%s)" START_PPSS=`get_time_in_seconds`
STOP_PPSS="" STOP_PPSS=""
SSH_SERVER="" # Remote server or 'master'. SSH_SERVER="" # Remote server or 'master'.
@ -1007,7 +1022,12 @@ deploy_ppss () {
for NODE in `cat $NODES_FILE` for NODE in `cat $NODES_FILE`
do do
deploy "$NODE" & deploy "$NODE" &
sleep 0.1 if [ "$ARCH" == "SunOS" ]
then
sleep 1
else
sleep 0.1
fi
if [ "$NODE" == "$SSH_SERVER" ] if [ "$NODE" == "$SSH_SERVER" ]
then then
log DEBUG "SSH SERVER $SSH_SERVER is also a node." log DEBUG "SSH SERVER $SSH_SERVER is also a node."
@ -1175,7 +1195,12 @@ random_delay () {
NUMBER=$RANDOM NUMBER=$RANDOM
let "NUMBER %= $ARGS" let "NUMBER %= $ARGS"
sleep "0.$NUMBER" if [ "$ARCH" == "SunOS" ]
then
sleep "$NUMBER"
else
sleep "0.$NUMBER"
fi
} }
@ -1540,8 +1565,13 @@ start_single_worker () {
stop-ppss () { stop-ppss () {
STOP_PPSS="$(date +%s)" if [ "$ARCH" == "SunOS" ]
elapsed "$START_PPSS" "$STOP_PPSS" then
STOP_PPSS=`truss /usr/bin/date 2>&1 | grep ^time | awk '{ print $3 }'`
else
STOP_PPSS="$(date +%s)"
fi
elapsed "$START_PPSS" "$STOP_PPSS"
} }
@ -1717,7 +1747,7 @@ commando () {
# The actual execution of the command as specified by # The actual execution of the command as specified by
# the -c option. # the -c option.
# #
BEFORE="$(date +%s)" BEFORE=`get_time_in_seconds`
TMP=`echo $COMMAND | grep -i '$ITEM'` TMP=`echo $COMMAND | grep -i '$ITEM'`
if [ "$?" == "0" ] if [ "$?" == "0" ]
then then
@ -1729,7 +1759,7 @@ commando () {
ERROR="$?" ERROR="$?"
MYPID="$!" MYPID="$!"
fi fi
AFTER="$(date +%s)" AFTER=`get_time_in_seconds`
echo -e "" >> "$ITEM_LOG_FILE" echo -e "" >> "$ITEM_LOG_FILE"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
DEBUG="$1" DEBUG="$1"
VERSION="2.60" VERSION="2.61"
TMP_DIR="ppss" TMP_DIR="ppss"
PPSS=./ppss PPSS=./ppss
PPSS_DIR=ppss_dir PPSS_DIR=ppss_dir