diff --git a/cryosparcm.sh b/cryosparcm.sh index e7566d5..e8a621f 100755 --- a/cryosparcm.sh +++ b/cryosparcm.sh @@ -1,90 +1,90 @@ #!/usr/bin/env bash set -euo pipefail install_path="$HOME"/cryosparc # Usage usage () { echo "$0 -p -P command" echo "Usage:" echo " command : command to pass to cryosparcm (start|stop)" echo " -p install path : prefix for installation [${install_path}] " echo " -P base_port : base port [39000] " echo " -v : be verbose" echo " -h : print this notice" echo "" } set +u if [ "x$1" = "x" ]; then usage exit 1 fi set -u # Parse options while getopts ":P:p:h" opt; do case $opt in p) install_path="${OPTARG}" ;; P) cryosparcm_port="${OPTARG}" ;; h) usage OPTIND=1 exit 0 ;; \?) echo "Invalid option: -$OPTARG" >&2 usage OPTIND=1 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 usage OPTIND=1 exit 1 ;; esac done shift $((OPTIND-1)) OPTIND=1 command=$1 shift module load gcc cuda python export PATH=${install_path}/cryosparc_master/bin:$PATH cryosparcm_path="$(which cryosparcm 2> /dev/null)" base_dir=$(dirname "$(dirname "${cryosparcm_path}")") master_host=$(hostname) if [ $master_host = "izar3" ]; then master_host=$master_host.hpc.epfl.ch else master_host=$master_host.epfl.ch fi cp $base_dir/config.sh $base_dir/config.sh.bak sed -i -e 's/export CRYOSPARC_MASTER_HOSTNAME.*$/export CRYOSPARC_MASTER_HOSTNAME=\"'"$master_host"'\"/g' $base_dir/config.sh sed -i -e 's/export CRYOSPARC_HOSTNAME_CHECK.*$/export CRYOSPARC_HOSTNAME_CHECK=\"'"$master_host"'\"/g' $base_dir/config.sh set +u if [ "x${cryosparcm_port}" != "x" ]; then sed -i -e 's/export CRYOSPARC_BASE_PORT.*$/export CRYOSPARC_BASE_PORT='$cryosparcm_port'/g' $base_dir/config.sh fi set -u source $base_dir/config.sh -${cryosparcm_path} $command $* +${cryosparcm_path} $command $* | sed -e 's/'$(hostname --fqdn)'/'${master_host}'/' if [[ $command =~ '.*start' ]]; then ${cryosparcm_path} status fi