osa-docker.sh 2.02 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
for directory in "$REP_BASE_PROD/scw" "$REP_BASE_PROD/aux" "$CURRENT_IC/ic" "$CURRENT_IC/idx" "$WORKDIR"; do
25 26
    [ -h $directory ] || { echo -e "\033[033mWARNING: directory \"$directory\" is a symlink, which may break since inside the container the filesystem layout is different\033[0m"; }
    [ -d $directory ] || { echo -e "\033[31mERROR: directory \"$directory\" should exist\033[0m"; exit 1; }
27 28 29 30
done

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

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

44 45


46 47
export HOME_OVERRRIDE=/home/integral

48 49
. init.sh

50 51 52 53 54 55 56 57 58
## check from isside now

for directory in \$REP_BASE_PROD/scw \$REP_BASE_PROD/aux \$CURRENT_IC/ic \$CURRENT_IC/idx; do
    [ -h \$directory ] || { echo -e \"\\033[033mWARNING: inside the container, directory \\\"\$directory\\\" exits, but is a symlink, which may break since inside the container the filesystem layout is different\\033[0m\"; }
    [ -d \$directory ] || { echo -e \"\\033[31mERROR: inside the container, directory \\\"\$directory\\\" should exist\\033[0m\"; exit 1; }
done

## done

59
cd \$HOME
60

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

$COMMAND
64

65
"