Changeset 2722 in /cluster/svnroot


Ignore:
Timestamp:
Oct 13, 2010 11:10:50 PM (10 years ago)
Author:
skylar
Message:

fixing pipe bug in bccd-syncdir (#535)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/trunk/trees/bin/bccd-syncdir

    r2589 r2722  
    1414
    1515if test "x$1" = "x--ni"; then
    16   NI=true
    17  
    18   DIRECTORY=$2
    19   MACHINEFILE=$3
     16    NI=true
     17   
     18    DIRECTORY=$2
     19    MACHINEFILE=$3
    2020elif test -n "$1" && test -z "$2"; then
    21         DIRECTORY=$1
    22         MACHINEFILE=$HOME/machines
    23         if ! test -r $MACHINEFILE; then
    24                 echo "Can't read $MACHINEFILE!"
    25                 exit 2
    26         fi
     21    DIRECTORY=$1
     22    MACHINEFILE=$HOME/machines
     23    if ! test -r $MACHINEFILE; then
     24        echo "Can't read $MACHINEFILE!"
     25        exit 2
     26    fi
    2727else
    28   DIRECTORY=$1
    29   MACHINEFILE=$2
     28    DIRECTORY=$1
     29    MACHINEFILE=$2
    3030fi
    3131
    3232if test -z $DIRECTORY -o -z $MACHINEFILE; then
    33   echo "syntax: $0 [directory] <hostfile>"
    34   echo "Example: $0 . ~/machines"
    35   exit -1;
     33    echo "syntax: $0 [directory] <hostfile>"
     34    echo "Example: $0 . ~/machines"
     35    exit -1;
    3636fi
    3737
    3838if test ! -d ${DIRECTORY} ; then
    39   echo ${DIRECTORY} is not a directory
    40   echo "syntax: $0 [directory] <hostfile>"
    41   echo "Example: $0 . ~/machines"
    42   exit -1;
     39    echo ${DIRECTORY} is not a directory
     40    echo "syntax: $0 [directory] <hostfile>"
     41    echo "Example: $0 . ~/machines"
     42    exit -1;
    4343fi
    4444
    45 if test -z $MACHINEFILE ; then
     45if test -z ${MACHINEFILE} ; then
    4646    echo "syntax: $0 [directory] <hostfile>"
    4747    echo "The default hostfile is ~/machines, but was not found"
    4848    exit -1;
    4949fi 
    50 NUMHOSTS=`wc -l ${MACHINEFILE} | awk '{print $1}'`
     50NUMHOSTS=$(awk '{i++} END {print i}' ${MACHINEFILE})
    5151
    5252if test  "${NUMHOSTS}" = "0"  -o -z ${NUMHOSTS}  ; then
    53   echo "You don't have any hosts to sync with"
    54   exit -1;
     53    echo "You don't have any hosts to sync with"
     54    exit -1;
    5555fi
    5656
    57 COMMONDIR=/tmp/`hostname -s`-$LOGNAME
    58 INCREMENT=`expr 100 / $NUMHOSTS`
     57COMMONDIR=/tmp/$(hostname -s)-${LOGNAME}
     58INCREMENT=$(expr 100 / $NUMHOSTS)
    5959
    60 echo NUMHOSTS is $NUMHOSTS
    61 echo INCREMENT is $INCREMENT
     60echo NUMHOSTS is ${NUMHOSTS}
     61echo INCREMENT is ${INCREMENT}
    6262
    63 (
    6463PCT=0
    65 for host in `cat ${MACHINEFILE}|awk '{print $1}'|sed -e s/:.*//` ; do
    66   PCT=`expr $PCT \+ ${INCREMENT}`
    67   echo "XXX"
    68   echo ${PCT}
    69   echo "Sync'ing with $host"
    70   echo "XXX"
    71   rsync -plar --delete $DIRECTORY/ $host:${COMMONDIR}/ 2>/dev/null
     64# Strip out CPU annotations from MPICH2 and OpenMPI
     65for host in $(awk '{gsub(/:.*/,"",$1); print $1}' ${MACHINEFILE}) ; do
     66    PCT=$(expr $PCT \+ ${INCREMENT})
     67    echo HERE ${host}
     68    echo "XXX"
     69    if test ! ${NI}; then
     70        echo ${PCT}|dialog --gauge "Syncing directory $DIRECTORY across hosts in $MACHINEFILE.  Target directory: $COMMONDIR" 6 60 0
     71    fi
     72    rsync -plar --delete $DIRECTORY/ $host:${COMMONDIR}/ 2>/dev/null
    7273done
    73 echo "XXX"
    74 echo "100"
    75 echo "XXX"
     74if test ! ${NI}; then
     75    echo 100|dialog --gauge "Syncing directory $DIRECTORY across hosts in $MACHINEFILE.  Target directory: $COMMONDIR" 6 60 0
     76fi
    7677sleep 2
    77 ) |
    78 if test ! $NI; then
    79 dialog --gauge "Syncing directory $DIRECTORY across hosts in $MACHINEFILE.  Target directory: $COMMONDIR" 6 60 0
    80 fi
    8178
    82 pushd $PWD
     79pushd ${PWD}
    8380cd /tmp
    8481
    85 if test ! $NI; then
     82if test ! ${NI}; then
    8683  dialog --title "${DIRECTORY} sync'd" --clear \
    87        --msgbox "The directory \"${DIRECTORY}\" has been sync'ed\
     84      --msgbox "The directory \"${DIRECTORY}\" has been sync'ed\
    8885                 across the machines in ${MACHINEFILE} to a\
    8986                 directory common to all hosts, \"${COMMONDIR}\"." 8 50
Note: See TracChangeset for help on using the changeset viewer.