got rid of getopts and did it by hand, much better

This commit is contained in:
Louwrentius 2009-02-27 19:14:38 +00:00
parent 2e76e5e34e
commit fc5d48b73c

99
ppss.sh
View File

@ -44,6 +44,7 @@ SCRIPT_VERSION="1.90"
MODE="$1" MODE="$1"
shift shift
ARGS=$@ ARGS=$@
CONFIG="config.cfg"
DAEMON=0 DAEMON=0
RUNNING_SIGNAL="$0_is_running" # Prevents running mutiple instances of PPSS.. RUNNING_SIGNAL="$0_is_running" # Prevents running mutiple instances of PPSS..
GLOBAL_LOCK="PPSS-GLOBAL-LOCK" # Global lock file used by local PPSS instance. GLOBAL_LOCK="PPSS-GLOBAL-LOCK" # Global lock file used by local PPSS instance.
@ -66,6 +67,7 @@ SSH_KEY="" # SSH key for ssh account.
SSH_SOCKET="/tmp/PPSS-ssh-socket" # Multiplex multiple SSH connections over 1 master. SSH_SOCKET="/tmp/PPSS-ssh-socket" # Multiplex multiple SSH connections over 1 master.
SSH_OPTS="-o BatchMode=yes -o ControlPath=$SSH_SOCKET -o ControlMaster=auto -o ConnectTimeout=5" SSH_OPTS="-o BatchMode=yes -o ControlPath=$SSH_SOCKET -o ControlMaster=auto -o ConnectTimeout=5"
SSH_MASTER_PID="" SSH_MASTER_PID=""
PPSS_HOME_DIR="ppss" PPSS_HOME_DIR="ppss"
ITEM_LOCK_DIR="PPSS_ITEM_LOCK_DIR" # Remote directory on master used for item locking. ITEM_LOCK_DIR="PPSS_ITEM_LOCK_DIR" # Remote directory on master used for item locking.
PPSS_LOCAL_WORKDIR="PPSS_LOCAL_WORKDIR" # Local directory on slave for local processing. PPSS_LOCAL_WORKDIR="PPSS_LOCAL_WORKDIR" # Local directory on slave for local processing.
@ -73,6 +75,7 @@ TRANSFER_TO_SLAVE="0" # Transfer item to slave via (s)cp.
SECURE_COPY="1" # If set, use SCP, Otherwise, use cp. SECURE_COPY="1" # If set, use SCP, Otherwise, use cp.
REMOTE_OUTPUT_DIR="" # Remote directory to which output must be uploaded. REMOTE_OUTPUT_DIR="" # Remote directory to which output must be uploaded.
showusage () { showusage () {
echo echo
@ -235,64 +238,98 @@ is_running () {
# exit 1 # exit 1
#fi #fi
if [ -e $CONFIG ]
then
echo HOER HOER HOER HOER HOER HOER HOER HOER HOER
source $CONFIG
echo $COMMAND
echo $SSH_SERVER
echo $USER
else
# Process any command-line options that are specified." # Process any command-line options that are specified."
while getopts ":Dbc:d:f:i:jhk:l:n:o:p:s:tu:v" OPTIONS while [ $# -gt 0 ]
do do
case $OPTIONS in case $1 in
n ) -n )
NODES_FILE="$OPTARG" NODES_FILE="$2"
shift 2
;; ;;
f ) -f )
INPUT_FILE="$OPTARG" INPUT_FILE="$2"
echo -e INPUT_FILE=\"$INPUT_FILE\" >> $CONFIG
shift 2
;; ;;
d ) -d )
SRC_DIR="$OPTARG" SRC_DIR="$2"
echo -e SRC_DIR=\"$SRC_DIR\" >> $CONFIG
shift 2
;; ;;
D ) -D )
DAEMON=1 DAEMON=1
echo -e DAEMON=1 >> $CONFIG
shift 2
;; ;;
c ) -c )
COMMAND="$OPTARG" COMMAND="$2"
echo -e COMMAND=\'$COMMAND\' >> $CONFIG
shift 2
;; ;;
h ) -h )
showusage showusage
exit 1;; exit 1;;
j ) -j )
HYPERTHREADING=yes HYPERTHREADING=yes
echo -e HYPERTHREADING=yes >> $CONFIG
shift 1
;; ;;
l ) -l )
LOGFILE="$OPTARG" LOGFILE="$2"
echo -e LOGFILE=\"$LOGFILE\" >> $CONFIG
shift 2
;; ;;
k ) -k )
SSH_KEY="-i $OPTARG" SSH_KEY="-i $2"
echo -e SSH_KEY=\"$SSH_KEY\"
shift 2
;; ;;
b ) -b )
SECURE_COPY=0 SECURE_COPY=0
echo -e SECURE_COPY=0 >> $CONFIG
shift 1
;; ;;
o ) -o )
REMOTE_OUTPUT_DIR="$OPTARG" REMOTE_OUTPUT_DIR="$2"
echo -e REMOTE_OUTPUT_DIR=\"$REMOTE_OUTPUT_DIR\" >> $CONFIG
shift 2
;; ;;
p ) -p )
TMP="$OPTARG" TMP="$2"
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
shift 2
fi fi
;; ;;
s ) -s )
SSH_SERVER="$OPTARG" SSH_SERVER="$2"
echo -e SSH_SERVER=\"$SSH_SERVER\" >> $CONFIG
shift 2
;; ;;
t ) -t )
TRANSFER_TO_SLAVE="1" TRANSFER_TO_SLAVE="1"
echo -e TRANSFER_TO_SLAVE=\"$TRANSFER_TO_SLAVE\" >> $CONFIG
;; ;;
u ) -u )
USER="$OPTARG" USER="$2"
echo -e USER=\"$USER\" >> $CONFIG
shift 2
;; ;;
v ) -v )
echo "" echo ""
echo "$SCRIPT_NAME version $SCRIPT_VERSION" echo "$SCRIPT_NAME version $SCRIPT_VERSION"
echo "" echo ""
@ -303,6 +340,11 @@ is_running () {
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 () {
@ -365,6 +407,7 @@ init_vars () {
if [ ! "$?" == "0" ] if [ ! "$?" == "0" ]
then then
echo "ERROR: remote output dir $REMOTE_OUTPUT_DIR does not exist." echo "ERROR: remote output dir $REMOTE_OUTPUT_DIR does not exist."
cleanup
exit exit
fi fi