osa-docker.sh 1.35 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 9
echo "OSA_VERSION == ${OSA_VERSION:=latest}"
echo "OSA_DOCKER_IMAGE == ${OSA_DOCKER_IMAGE:=integralsw/osa:${OSA_VERSION}}"
Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
10
echo "OSA_DOCKER_PULL == \"${OSA_DOCKER_PULL:=yes}\""
11 12

[ "x$OSA_DOCKER_PULL" == "xyes" ] && {
Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
13 14 15 16 17 18
    echo "will update image (set OSA_DOCKER_PULL to anything but \"yes\" to stop this)"
    docker pull $OSA_DOCKER_IMAGE
}

echo "."
echo "."
19
echo "REP_BASE_PROD: ${REP_BASE_PROD:?please set this variable to the current data location}"
20
echo "CURRENT_IC: ${CURRENT_IC:=$REP_BASE_PROD}"
21 22
echo "using WORKDIR: ${WORKDIR:=$PWD}"

Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
23

24 25 26 27 28 29
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!"; }

30 31 32 33 34 35 36 37 38 39
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 \
40
    --rm -it  --user $(id -u) --entrypoint='' \
Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
41
        ${OSA_DOCKER_IMAGE} bash -c "
42

43 44
export HOME_OVERRRIDE=/home/integral

45 46
. init.sh

47
cd \$HOME
48

49 50 51
ln -s /data/ic
ln -s /data/idx

52 53 54 55
echo -e '\\e[31mrunning\\e[37m $COMMAND\\e[0m'

$COMMAND
"