Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:47

0001 #!/bin/bash -l 
0002 
0003 CMD=$1
0004 usage(){ cat << EOU
0005 evtsync.sh 
0006 ===========
0007 
0008 rsyncs OpticksEvent .npy arrays and .json metadata between machines 
0009 
0010 ::
0011 
0012    PFX=tds3ip evtsync.sh  
0013    PFX=tds3gun evtsync.sh  
0014 
0015    PFX=tds3gun evtsync.sh rm     # deletes the destination dir before sync, for cleanliness
0016    PFX=tds3gun evtsync.sh ls     # skips the rsync, justs lists
0017  
0018 
0019 Example directories that are synced::
0020 
0021     evtsync from P:/tmp/blyth/opticks/tds3gun/evt/g4live/natural to /tmp/blyth/opticks/tds3gun/evt/g4live/natural
0022 
0023  
0024 EOU
0025 }
0026 
0027 
0028 REMOTE=${REMOTE:-P}
0029 #OPTICKS_EVENT_BASE_REMOTE=${OPTICKS_EVENT_BASE_REMOTE:-/home/$USER/local/opticks/evtbase}
0030 OPTICKS_EVENT_BASE_REMOTE=${OPTICKS_EVENT_BASE_REMOTE:-/tmp/$USER/opticks}
0031 OPTICKS_EVENT_BASE=${OPTICKS_EVENT_BASE:-/tmp/$USER/opticks}
0032 
0033 evtsync()
0034 {
0035    local msg="=== $FUNCNAME :"
0036    local reldir=${1}
0037    [ -z "$reldir" ] && echo $msg ERROR missing reldir arg && return 1 
0038 
0039    local from=$REMOTE:${OPTICKS_EVENT_BASE_REMOTE}/$reldir
0040    local to=${OPTICKS_EVENT_BASE}/$reldir
0041 
0042     echo $FUNCNAME from $from to $to
0043 
0044     if [ "$CMD" == "rm" -a -d "$to" ]; then 
0045        rm -rf $to   
0046     fi
0047     mkdir -p $to 
0048 
0049     local rc
0050 
0051     if [ "$CMD" != "ls" ]; then
0052         rsync -zarv --progress --include="*/" --include="*.npy" --include="*.txt" --include="*.json" --include="*.ini" --exclude="*" "${from}/" "${to}/"
0053         rc=$? 
0054         if [ $rc -ne 0 ]; then 
0055             echo $msg non-zero rc from rsync : start ssh tunnel with \"tun\" and ensure remote directory being grabbed exists && exit 1
0056         fi 
0057     fi 
0058     ls -1rt `find ${to%/} -name '*.npy' `
0059 
0060     return 0   
0061 }
0062 
0063 
0064 
0065 PFX=${PFX:-tds3gun}
0066 reldir=${PFX}/evt/g4live/natural 
0067 
0068 evtsync ${reldir}
0069 
0070