osa-docker.sh 1.31 KB
Newer Older
1 2
#!/bin/bash

Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
3
#set -xe
4 5 6

COMMAND=$@

Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
7

Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
8
echo "OSA_DOCKER_IMAGE == ${OSA_DOCKER_IMAGE:=integralsw/osa:latest}"
Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
9 10 11 12 13 14 15 16
echo "OSA_DOCKER_PULL == \"${OSA_DOCKER_PULL:=yes}\""
[ "$OSA_DOCKER_PULL" ==  "yes" ] && {
    echo "will update image (set OSA_DOCKER_PULL to anything but \"yes\" to stop this)"
    docker pull $OSA_DOCKER_IMAGE
}

echo "."
echo "."
17
echo "REP_BASE_PROD: ${REP_BASE_PROD:?please set this variable to the current data location}"
18
echo "CURRENT_IC: ${CURRENT_IC:?please set this variable to the current IC location (could be REP_BASE_PROD, but we would not like to assume...)}"
19 20
echo "using WORKDIR: ${WORKDIR:=$PWD}"

Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
21

22 23 24 25 26 27
for directory in "$REP_BASE_PROD/scw" "$REP_BASE_PROD/aux" "$CURRENT_IC/ic" "$CURRENT_IC/idx" "$WORKDIR"; do
    [ -d $directory ] || { echo "directory \"$directory\" should exist"; exit 1; }
done

[ -s /tmp/.X11-unix ] || { echo "no /tmp/.X11-unix? no X? not allowed!"; }

28 29 30 31 32 33 34 35 36 37 38
mkdir -pv $WORKDIR/pfiles

docker run \
    -e DISPLAY=$DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -v $WORKDIR:/home/integral \
    -v $REP_BASE_PROD/scw:/data/scw:ro \
    -v $REP_BASE_PROD/aux:/data/aux:ro \
    -v $CURRENT_IC/ic:/data/ic:ro \
    -v $CURRENT_IC/idx:/data/idx:ro \
    --rm -it  --user $(id -u) \
Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
39
        ${OSA_DOCKER_IMAGE} bash -c "
40 41 42 43 44 45 46 47 48

. init.sh

cd \$HOME

echo -e '\\e[31mrunning\\e[37m $COMMAND\\e[0m'

$COMMAND
"