#!/bin/bash # g4bldata - manage Geant4 data for G4beamline # # The Geant4 data is searched for in two places: # $G4BL_DIR/Geant4Data # $HOME/Geant4Data # --install will run the Java program G4blData, which searches in the # same two places. # # USAGE: g4bldata [--check] [--setenv] [--install] [--echo] # # --check check for the presence of the environment variables or # the $G4BL_DIR/Geant4Data directory; If present, a short # message is written to stdout; if neither is present, a # description of how to obtain the data is printed. # # --setenv ensure the environment variables are set up, print an # errormessage if the data are not found. # MUST be source-d. Does g4bldata --echo. # # --install download and unpack the data, and create a setup script # that sets up the environment variables. # # --install-no-gui as install, but without GUI. Requires wget. # # --echo echo the data environment variables to stdout (name=value\n) # # Otherwise, a short usage message is printed. # determine G4BL_DIR if test "$G4BL_DIR" = "" then G4BL_DIR=`dirname "$0"` G4BL_DIR=`\cd "$G4BL_DIR" >&- 2>&- && pwd` G4BL_DIR=`dirname "$G4BL_DIR"` if test -x /bin/cygpath then G4BL_DIR=`/bin/cygpath -m "$G4BL_DIR"` fi fi export G4BL_DIR if test ! -r "$G4BL_DIR/bin/g4bldata" then echo "g4bldata: ERROR -- cannot determine G4BL_DIR." echo " This script must be run via an absolute path." exit 1 fi # check for environment variables ENV_OK=false if test "$G4LEDATA " -a "$G4LEVELGAMMADATA" then ENV_OK=true fi if test "$1" = "--echo" then if ! $ENV_OK then if test -r "$G4BL_DIR/Geant4Data/setup.sh" then source "$G4BL_DIR/Geant4Data"/setup.sh elif test -r "$HOME/Geant4Data/setup.sh" then source "$HOME/Geant4Data/setup.sh" else echo >&2 "g4bldata: ERROR -- cannot find Geant4Data." exit 1 fi fi if test "$G4ABLADATA"; then echo G4ABLADATA=$G4ABLADATA; fi if test "$G4LEDATA"; then echo G4LEDATA=$G4LEDATA; fi if test "$G4NEUTRONHPDATA"; then echo G4NEUTRONHPDATA=$G4NEUTRONHPDATA; fi if test "$G4NEUTRONXSDATA"; then echo G4NEUTRONXSDATA=$G4NEUTRONXSDATA; fi if test "$G4PIIDATA"; then echo G4PIIDATA=$G4PIIDATA; fi if test "$G4LEVELGAMMADATA"; then echo G4LEVELGAMMADATA=$G4LEVELGAMMADATA; fi if test "$G4RADIOACTIVEDATA"; then echo G4RADIOACTIVEDATA=$G4RADIOACTIVEDATA; fi if test "$G4REALSURFACEDATA"; then echo G4REALSURFACEDATA=$G4REALSURFACEDATA; fi exit 0 fi if test "$1" = "--check" then if $ENV_OK then echo "g4bldata: The Geant4 data environment variables are set." echo " They must remain set whenever G4beamline is run." exit 0 fi if test -d "$G4BL_DIR/Geant4Data" -o -d "$HOME/Geant4Data" then echo "g4bldata: The Geant4Data directory is present." echo " This instance of G4beamline will find the data." exit 0 fi cat <&2 "g4bldata: ERROR -- cannot find Geant4Data." return 1 fi if test "$1" = "--install" then case `uname -s` in Darwin*) JAVAOPTS="-Xdock:icon=$G4BL_DIR/share/g4beamline/G4blDataIcon.icns" ;; *) JAVAOPTS='' ;; esac java $JAVAOPTS -classpath $G4BL_DIR/share/g4beamline G4blData exit fi echo "g4bldata: ERROR -- invalid argument." echo "USAGE: g4bldata [--echo] [--check] [--setenv] [--install]" echo " --echo will echo the Geant4 environment variables to stdout." echo " --check will check for the presence of the data." echo " --setenv will set up the environment data, MUST be source-d." echo " --install will install the data; 400 MB download, 1.5GB on disk." exit 1