osa-docker.sh 2.08 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
Carlo Ferrigno's avatar
Carlo Ferrigno committed
25
26
27
28
29
30
31
32
    if [ -L $directory ] ; then 
	    echo -e "\033[033mWARNING: directory \"$directory\" is a symlink, which may break since inside the container the filesystem layout is different\033[0m"; 
    fi

    if [ ! -d $directory ] ; then 
	    echo -e "\033[31mERROR: directory \"$directory\" should exist\033[0m"
	    exit 1
    fi
33
34
35
36
done

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

37
38
39
40
41
42
43
44
45
46
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 \
47
    --rm -it  --user $(id -u) --entrypoint='' \
Volodymyr SAVCHENKO's avatar
Volodymyr SAVCHENKO committed
48
        ${OSA_DOCKER_IMAGE} bash -c "
49

50
51


52
53
export HOME_OVERRRIDE=/home/integral

54
55
. init.sh

Carlo Ferrigno's avatar
Carlo Ferrigno committed
56
57
58
59
60
61
62
63
64
65
66
## check from inside now

for directory in /data/scw /data/aux /data/ic /data/idx; do
    if [ -L \$directory ] ; then 
	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\"
    fi
    ls -ldA \$directory
    if [ ! -d \$directory ] ; then  
	    echo -e \"\\033[31mERROR: inside the container, directory \\\"\$directory\\\" should exist\\033[0m\"
	    exit 1;
    fi
67
68
69
70
done

## done

71
cd \$HOME
72

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

$COMMAND
76

77
"