some rework

This commit is contained in:
Louwrentius 2009-12-16 18:29:18 +00:00
parent 20e520e820
commit f2ccafefc6

46
ppss.sh
View File

@ -55,7 +55,8 @@ done
# export PPSS_DIR=/path/to/workingdir # export PPSS_DIR=/path/to/workingdir
if [ -z "$PPSS_DIR" ] if [ -z "$PPSS_DIR" ]
then then
PPSS_DIR="ppss" PWD=`pwd`
PPSS_DIR="$PWD/ppss"
fi fi
if [ ! -e "$PPSS_DIR" ] if [ ! -e "$PPSS_DIR" ]
@ -174,6 +175,10 @@ showusage_normal () {
if [ "$#" == "0" ] if [ "$#" == "0" ]
then then
showusage_short showusage_short
if [ -e "$PPSS_DIR" ]
then
rm -rf "$PPSS_DIR"
fi
exit 1 exit 1
fi fi
@ -449,9 +454,17 @@ do
-h ) -h )
showusage_normal showusage_normal
if [ -e "$PPSS_DIR" ]
then
rm -rf "$PPSS_DIR"
fi
exit 1;; exit 1;;
--help) --help)
showusage_long showusage_long
if [ -e "$PPSS_DIR" ]
then
rm -rf "$PPSS_DIR"
fi
exit 1;; exit 1;;
--homedir|-H ) --homedir|-H )
if [ ! -z "$2" ] if [ ! -z "$2" ]
@ -1362,7 +1375,9 @@ commando () {
ITEM_NO_PATH=`basename "$ITEM"` ITEM_NO_PATH=`basename "$ITEM"`
escape_item "$ITEM_NO_PATH" escape_item "$ITEM_NO_PATH"
OUTPUT_DIR=$PPSS_LOCAL_OUTPUT/"$ITEM_ESCAPED" OUTPUT_DIR=$PPSS_LOCAL_OUTPUT/"$ITEM_ESCAPED"
# This VAR can be used in scripts or command lines. # ^
# | This VAR can be used in scripts or command lines.
#
OUTPUT_FILE="$ITEM_ESCAPED" OUTPUT_FILE="$ITEM_ESCAPED"
else else
DIRNAME="" DIRNAME=""
@ -1372,14 +1387,15 @@ commando () {
fi fi
log DEBUG "Processing item $ITEM" log DEBUG "Processing item $ITEM"
#
#Decide if an item must be transfered to the node. # Decide if an item must be transfered from server to the node.
#or be processed in-place (NFS / SMB mount?) # or be processed in-place (NFS / SMB mount?)
#
if [ "$TRANSFER_TO_SLAVE" == "0" ] if [ "$TRANSFER_TO_SLAVE" == "0" ]
then then
if [ -z "$SRC_DIR" ] && [ ! -z "$INPUT_FILE" ] if [ -z "$SRC_DIR" ] && [ ! -z "$INPUT_FILE" ]
then then
log DEBUG "Using item straight from INPUT FILE" log DEBUG "Using item straight from the server."
else else
ITEM="$SRC_DIR/$ITEM" ITEM="$SRC_DIR/$ITEM"
fi fi
@ -1399,33 +1415,32 @@ commando () {
then then
log DEBUG "Skipping item $ITEM - already processed." log DEBUG "Skipping item $ITEM - already processed."
else else
ERROR="" ERROR=""
#
# Some formatting of item log files. # Some formatting of item log files.
#
DATE=`date +%b\ %d\ %H:%M:%S` DATE=`date +%b\ %d\ %H:%M:%S`
echo "===== PPSS Item Log File =====" > "$ITEM_LOG_FILE" echo "===== PPSS Item Log File =====" > "$ITEM_LOG_FILE"
echo -e "Host:\t\t$HOSTNAME" >> "$ITEM_LOG_FILE" echo -e "Host:\t\t$HOSTNAME" >> "$ITEM_LOG_FILE"
echo -e "Process:$PID" >> "$ITEM_LOG_FILE" echo -e "Process:\t$PID" >> "$ITEM_LOG_FILE"
echo -e "Item:\t\t$ITEM" >> "$ITEM_LOG_FILE" echo -e "Item:\t\t$ITEM" >> "$ITEM_LOG_FILE"
echo -e "Start date:\t$DATE" >> "$ITEM_LOG_FILE" echo -e "Start date:\t$DATE" >> "$ITEM_LOG_FILE"
echo -e "" >> "$ITEM_LOG_FILE" echo -e "" >> "$ITEM_LOG_FILE"
#
# The actual execution of the command. # The actual execution of the command.
#
BEFORE="$(date +%s)"
TMP=`echo $COMMAND | grep -i '$ITEM'` TMP=`echo $COMMAND | grep -i '$ITEM'`
if [ "$?" == "0" ] if [ "$?" == "0" ]
then then
BEFORE="$(date +%s)"
eval "$COMMAND" >> "$ITEM_LOG_FILE" 2>&1 eval "$COMMAND" >> "$ITEM_LOG_FILE" 2>&1
ERROR="$?" ERROR="$?"
AFTER="$(date +%s)"
else else
EXECME='$COMMAND$ITEM >> "$ITEM_LOG_FILE" 2>&1' eval '$COMMAND"$ITEM" >> "$ITEM_LOG_FILE" 2>&1'
BEFORE="$(date +%s)"
eval "$EXECME"
ERROR="$?" ERROR="$?"
AFTER="$(date +%s)"
fi fi
AFTER="$(date +%s)"
echo -e "" >> "$ITEM_LOG_FILE" echo -e "" >> "$ITEM_LOG_FILE"
@ -1520,6 +1535,7 @@ listen_for_job () {
then then
kill "$SSH_MASTER_PID" kill "$SSH_MASTER_PID"
fi fi
echo
log INFO "Finished. Consult ./$JOB_LOG_DIR for job output." log INFO "Finished. Consult ./$JOB_LOG_DIR for job output."
break break
else else