broken en messed up - just a backup

This commit is contained in:
Louwrentius 2009-02-28 08:40:11 +00:00
parent fc5d48b73c
commit cacb489c14

147
ppss.sh
View File

@ -136,7 +136,6 @@ kill_process () {
then then
kill -9 "$SSH_MASTER_PID" kill -9 "$SSH_MASTER_PID"
fi fi
log INFO "Finished."
echo "" echo ""
exit 0 exit 0
fi fi
@ -190,7 +189,7 @@ check_for_interrupt () {
cleanup () { cleanup () {
log DEBUG "$FUNCNAME - Cleaning up all temp files and processes." #log DEBUG "$FUNCNAME - Cleaning up all temp files and processes."
if [ -e "$FIFO" ] if [ -e "$FIFO" ]
then then
@ -231,26 +230,55 @@ is_running () {
fi fi
} }
# If no arguments are specified, show usage.
#if [ $# -eq 0 ]
#then
# showusage
# exit 1
#fi
if [ -e $CONFIG ] add_var_to_config () {
if [ "$MODE" == "config" ]
then then
echo HOER HOER HOER HOER HOER HOER HOER HOER HOER
source $CONFIG VAR="$1"
echo $COMMAND VALUE="$2"
echo $SSH_SERVER
echo $USER echo -e "$VAR=$VALUE" >> $CONFIG
else fi
}
# Process any command-line options that are specified." # Process any command-line options that are specified."
while [ $# -gt 0 ] while [ $# -gt 0 ]
do do
case $1 in case $1 in
-config )
CONFIG=$2
if [ "$MODE" == "config" ]
then
if [ -e "$CONFIG" ]
then
echo "Do want to overwrite existing config file?"
read yn
if [ "$yn" == "y" ]
then
rm "$CONFIG"
else
echo "Aborting..."
cleanup
exit
fi
fi
fi
if [ ! "$MODE" == "config" ]
then
source $CONFIG
fi
if [ ! -z "$SSH_KEY" ]
then
SSH_KEY="-i $SSH_KEY"
fi
shift 2
;;
-n ) -n )
NODES_FILE="$2" NODES_FILE="$2"
shift 2 shift 2
@ -258,22 +286,23 @@ else
-f ) -f )
INPUT_FILE="$2" INPUT_FILE="$2"
echo -e INPUT_FILE=\"$INPUT_FILE\" >> $CONFIG add_var_to_config INPUT_FILE "$INPUT_FILE"
shift 2 shift 2
;; ;;
-d ) -d )
SRC_DIR="$2" SRC_DIR="$2"
echo -e SRC_DIR=\"$SRC_DIR\" >> $CONFIG add_var_to_config SRC_DIR "$SRC_DIR"
shift 2 shift 2
;; ;;
-D ) -D )
DAEMON=1 DAEMON=1
echo -e DAEMON=1 >> $CONFIG add_var_to_config DAEMON "$DAEMON"
shift 2 shift 2
;; ;;
-c ) -c )
COMMAND="$2" COMMAND=$2
echo -e COMMAND=\'$COMMAND\' >> $CONFIG COMMAND=\'$COMMAND\'
add_var_to_config COMMAND "$COMMAND"
shift 2 shift 2
;; ;;
@ -282,27 +311,31 @@ else
exit 1;; exit 1;;
-j ) -j )
HYPERTHREADING=yes HYPERTHREADING=yes
echo -e HYPERTHREADING=yes >> $CONFIG add_var_to_config HYPERTHREADING "yes"
shift 1 shift 1
;; ;;
-l ) -l )
LOGFILE="$2" LOGFILE="$2"
echo -e LOGFILE=\"$LOGFILE\" >> $CONFIG add_var_to_config LOGFILE "$LOGFILE"
shift 2 shift 2
;; ;;
-k ) -k )
SSH_KEY="-i $2" SSH_KEY="$2"
echo -e SSH_KEY=\"$SSH_KEY\" add_var_to_config SSH_KEY "$SSH_KEY"
if [ ! -z "$SSH_KEY" ]
then
SSH_KEY="-i $SSH_KEY"
fi
shift 2 shift 2
;; ;;
-b ) -b )
SECURE_COPY=0 SECURE_COPY=0
echo -e SECURE_COPY=0 >> $CONFIG add_var_to_config SECURE_COPY "$SECURE_COPY"
shift 1 shift 1
;; ;;
-o ) -o )
REMOTE_OUTPUT_DIR="$2" REMOTE_OUTPUT_DIR="$2"
echo -e REMOTE_OUTPUT_DIR=\"$REMOTE_OUTPUT_DIR\" >> $CONFIG add_var_to_config REMOTE_OUTPUT_DIR "$REMOTE_OUTPUT_DIR"
shift 2 shift 2
;; ;;
-p ) -p )
@ -310,22 +343,22 @@ else
if [ ! -z "$TMP" ] if [ ! -z "$TMP" ]
then then
MAX_NO_OF_RUNNING_JOBS="$TMP" MAX_NO_OF_RUNNING_JOBS="$TMP"
echo -e MAX_NO_OF_RUNNING_JOBS=\"$MAX_NO_OF_RUNNING_JOBS\" >> $CONFIG add_var_to_config MAX_NO_OF_RUNNING_JOBS "$MAX_NO_OF_RUNNING_JOBS"
shift 2 shift 2
fi fi
;; ;;
-s ) -s )
SSH_SERVER="$2" SSH_SERVER="$2"
echo -e SSH_SERVER=\"$SSH_SERVER\" >> $CONFIG add_var_to_config SSH_SERVER "$SSH_SERVER"
shift 2 shift 2
;; ;;
-t ) -t )
TRANSFER_TO_SLAVE="1" TRANSFER_TO_SLAVE="1"
echo -e TRANSFER_TO_SLAVE=\"$TRANSFER_TO_SLAVE\" >> $CONFIG add_var_to_config TRANSFER_TO_SLAVE "$TRANSFER_TO_SLAVE"
;; ;;
-u ) -u )
USER="$2" USER="$2"
echo -e USER=\"$USER\" >> $CONFIG add_var_to_config USER "$USER"
shift 2 shift 2
;; ;;
@ -340,11 +373,6 @@ else
exit 1;; exit 1;;
esac esac
done done
fi
echo $COMMAND
echo $SSH_SERVER
echo $USER
# Init all vars # Init all vars
init_vars () { init_vars () {
@ -502,6 +530,8 @@ deploy_ppss () {
set_error $? set_error $?
scp -q $KEY $USER@$NODE:~/$PPSS_HOME_DIR scp -q $KEY $USER@$NODE:~/$PPSS_HOME_DIR
set_error $? set_error $?
scp -q $CONFIG $USER@$NODE:~/$PPSS_HOME_DIR
set_error $?
if [ "$ERROR" == "0" ] if [ "$ERROR" == "0" ]
then then
log INFO "PPSS installed on node $NODE." log INFO "PPSS installed on node $NODE."
@ -514,32 +544,12 @@ deploy_ppss () {
start_ppss_on_node () { start_ppss_on_node () {
# USER NODE="$1"
# NODE
# PATH OF PPSS
# execute with command line args.
if [ ! -e "$NODES_FILE" ]
then
log INFO "ERROR file $NODES with list of nodes does not exist."
exit 1
else
for NODE in `cat $NODES_FILE`
do
echo "----> ARGS IS $ARGS"
#ssh $USER@$NODE cd $PPSS_HOME_DIR ; screen -S PPSS ./$0 node #ssh $USER@$NODE cd $PPSS_HOME_DIR ; screen -S PPSS ./$0 node
CMD=""
for (( i = 1; i <= $# ; i++ )); do
eval ARG=\$$i
CMD="$CMD $(echo "$ARG" | awk '{gsub(".", "\\\\&");print}')"
done
#ssh $USER@$NODE "cd $PPSS_HOME_DIR ; pwd ; screen -d -m -S PPSS ./ppss.sh node "$CMD" ; exit" #ssh $USER@$NODE "cd $PPSS_HOME_DIR ; pwd ; screen -d -m -S PPSS ./ppss.sh node "$CMD" ; exit"
ssh $USER@$NODE "cd $PPSS_HOME_DIR ; pwd ; ./ppss.sh node $CMD" ssh $USER@$NODE "cd $PPSS_HOME_DIR ; hostname ; screen -d -m -S PPSS ./ppss.sh node -config $CONFIG"
done
fi
} }
@ -988,10 +998,29 @@ main () {
LISTENER_PID=$! LISTENER_PID=$!
start_all_workers start_all_workers
;; ;;
start ) server )
# This option only starts all nodes.
init_vars init_vars
start_ppss_on_node
if [ ! -e "$NODES_FILE" ]
then
log INFO "ERROR file $NODES with list of nodes does not exist."
cleanup
exit 1
else
for NODE in `cat $NODES_FILE`
do
start_ppss_on_node "$NODE"
done
fi
;; ;;
config )
log INFO "Generating configuration file $CONFIG"
cleanup
exit
;;
stop ) stop )
#some stop #some stop
;; ;;