Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:00

0001 #!/bin/bash -l 
0002 usage(){ cat << EOU
0003 cachegrab.sh 
0004 =============
0005 
0006 This is intended for source usage from other scripts such as cxsim.sh  
0007 
0008 * grab.sh has become too organic : so try collecting just the essentials here 
0009 
0010 Runs rsync grabbing into local directories files from a remote geocache/CSG_GGeo/EXECUTABLE 
0011 directory into which executable outputs such as cxs jpg renders, json sidecars 
0012 and intersect "photon" arrays are persisted.
0013 
0014 The remote cache directory to grab from is configurable with envvar OPTICKS_KEY_REMOTE 
0015 which is the OPTICKS_KEY from a remote node. The OPTICKS_KEY_REMOTE is converted
0016 into a remote directory by bash function opticks-key-remote-dir which uses SOpticksResourceTest 
0017 executable.
0018 
0019     OPTICKS_KEY_REMOTE     : $OPTICKS_KEY_REMOTE
0020     opticks-key-remote-dir : $(opticks-key-remote-dir)
0021 
0022 EOU
0023 }
0024 
0025 msg="=== $BASH_SOURCE :"
0026 grab_arg=${1:-grab}
0027 shift
0028 
0029 if [ "${grab_arg}"  == "help" ]; then
0030    usage
0031    exit 0
0032 fi 
0033 
0034 
0035 
0036 executable=CSGOptiXSimTest
0037 EXECUTABLE=${EXECUTABLE:-$executable}
0038 CGREL=${CGREL:-CSG_GGeo}
0039 
0040 case $EXECUTABLE in 
0041    CSGOptiXSimTest)      echo $msg expected EXECUTABLE $EXECUTABLE  ;; 
0042    CSGOptiXSimtraceTest) echo $msg expected EXECUTABLE $EXECUTABLE  ;;
0043                       *) echo $msg unexpected EXECUTABLE $EXECUTABLE  ;;
0044 esac
0045 
0046 opticks_key_remote_dir=$(opticks-key-remote-dir)    ## eg .opticks/geocache/DetSim0Svc_pWorld_g4live/g4ok_gltf/41c046fe05b28cb70b1fc65d0e6b7749/1
0047 
0048 xbase=$opticks_key_remote_dir/$CGREL
0049 xdir=$xbase/$EXECUTABLE/             ## trailing slash to avoid rsync duplicating path element 
0050 
0051 from=P:$xdir
0052 to=$HOME/$xdir
0053 cfbase=$HOME/$xbase
0054 fold=$cfbase/$EXECUTABLE
0055 
0056 vars="grab_arg EXECUTABLE OPTICKS_KEY_REMOTE opticks_key_remote_dir xdir from to"
0057 dumpvars(){ for var in $vars ; do printf "%-30s : %s \n" $var "${!var}" ; done ; }
0058 dumpvars
0059 
0060 if [ "${grab_arg}" == "env" ]; then 
0061     export FOLD=$cfbase/$EXECUTABLE        # used by opticks.ana.fold
0062     export CFBASE=$cfbase    # used by opticks.CSG.CSGFoundry 
0063     export CAP_BASE=$cfbase/$EXECUTABLE/figs
0064     ## CAP_REL and CAP_STEM are set by specific scripts such as cxs_debug.sh 
0065     vars="FOLD CFBASE CAP_BASE"
0066     dumpvars
0067 fi 
0068 
0069 if [ "${grab_arg}" == "grab" ]; then 
0070     read -p "$msg Enter YES to proceed with rsync between from and to " ans
0071     if [ "$ans" == "YES" ]; then 
0072         echo $msg proceeding 
0073         mkdir -p $to
0074         rsync -zarv --progress --include="*/" --include="*.txt" --include="*.npy" --include="*.jpg" --include="*.mp4" --include "*.json" --exclude="*" "$from" "$to"
0075         ls -1rt `find ${to%/} -name '*.json' -o -name '*.txt' `
0076         ls -1rt `find ${to%/} -name '*.jpg' -o -name '*.mp4' -o -name '*.npy'  `
0077     else
0078        echo $msg skipping : perhaps you should be using tmp_grab.sh 
0079     fi 
0080 fi 
0081 
0082