forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_launcher.sh
executable file
·41 lines (41 loc) · 1.62 KB
/
docker_launcher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash -ex
for cvmfs_dir in $(grep CVMFS_REPOSITORIES= /etc/cvmfs/default.local | sed "s|.*=||;s|'||g" | sed 's|"||g' | tr ',' '\n' | grep cern.ch) ; do
ls -l /cvmfs/${cvmfs_dir} >/dev/null 2>&1 || true
done
RUN_NATIVE=
if [ "X$DOCKER_IMG" = "X" -a "$DOCKER_IMG_HOST" != "X" ] ; then DOCKER_IMG=$DOCKER_IMG_HOST ; fi
if [ "X$NOT_RUN_DOCKER" != "X" -a "X$DOCKER_IMG" != "X" ] ; then
RUN_NATIVE=`echo $DOCKER_IMG | grep "$NOT_RUN_DOCKER"`
fi
if [ "X$DOCKER_IMG" != X -a "X$RUN_NATIVE" = "X" ]; then
DOCKER_EXTRA_ENV=""
for e in $DOCKER_JOB_ENV ; do DOCKER_EXTRA_ENV="${DOCKER_EXTRA_ENV} -e $e=$(eval echo \$$e)"; done
docker pull $DOCKER_IMG
XUSER=`whoami`
DOCKER_OPT=""
case $XUSER in
cmsbld ) DOCKER_OPT=" -u $(id -u):$(id -g) -v /etc/passwd:/etc/passwd -v /etc/group:/etc/group " ;;
esac
if [ -e /etc/tnsnames.ora ] ; then
DOCKER_OPT="$DOCKER_OPT -v /etc/tnsnames.ora:/etc/tnsnames.ora "
fi
DOCK_ARGS="voms-proxy-init -voms cms -valid 24:00|| true ; cd $WORKSPACE; $@"
echo "Passing to docker the args: "$DOCK_ARGS
docker run --rm -h `hostname -f` $DOCKER_OPT \
-v /etc/localtime:/etc/localtime \
-v /build/$XUSER:/build/$XUSER \
-v /home/$XUSER:/home/$XUSER \
-v /cvmfs:/cvmfs \
-v /cvmfs/grid.cern.ch/etc/grid-security/vomses:/etc/vomses \
-v /cvmfs/grid.cern.ch/etc/grid-security:/etc/grid-security \
-v /tmp:/tmp \
-e WORKSPACE=$WORKSPACE \
-e USER=$USER \
-e BUILD_NUMBER=$BUILD_NUMBER \
-e JOB_NAME=$JOB_NAME \
-e KRB5CCNAME=$KRB5CCNAME $DOCKER_EXTRA_ENV \
$DOCKER_IMG sh -c "$DOCK_ARGS"
else
voms-proxy-init -voms cms -valid 24:00 || true
eval $@
fi