-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·99 lines (89 loc) · 2.94 KB
/
setup.sh
File metadata and controls
executable file
·99 lines (89 loc) · 2.94 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# EUDAQ integration docker image setup
# Run it first time to create all the needed
# infrastructure,
#!/bin/bash
#
# Setup the enviroment to use the EUDAQ docker
# container. It will create in the host machine
# - $HOME/eudaq_data/logs -> the logs files created by the logger
# - $HOME/eudaq_data/data -> the raw data
# - $HOME/repos/eudaq -> the cloned EUDAQ source
# - the docker-compose yaml files
#
# jorge.duarte.campderros@cern.ch (CERN/IFCA)
#
# 1. Check it is running as regular user
if [ "${EUID}" -eq 0 ];
then
echo "Do not run this as root"
exit -2
fi
# 2. Check if the setup was run:
if [ -e ".setupdone" ];
then
echo "DO NOT DOING ANYTHING, THE SETUP WAS ALREADY DONE:"
echo "=================================================="
cat .setupdone
exit -3
fi
DOCKERDIR=${PWD}
# 3. Download the code: XXX This can be done in the image actually
CODEDIR=${HOME}/repos/eudaq
mkdir -p ${CODEDIR} && cd ${CODEDIR}/.. ;
if [ "X$(command -v git)" == "X" ];
then
echo "You will need to install git (https://git-scm.com/)"
exit -1;
fi
echo "Cloning EUDAQ into : $(pwd)"
git clone https://github.com/duartej/eudaq.git eudaq
if [ "$?" -eq 128 ];
then
echo "Repository already available at '${CODEDIR}'"
echo "Remove it if you want to re-clone it"
else
# Change to the v1.x-dev
echo "Switch to v1.x-dev"
cd ${CODEDIR} && git checkout v1.x-dev
echo "======================================================="
echo "If this is for developing purposes, it is convenient to"
echo "fork the https://github.com/eudaq/eudaq.git into your "
echo "github account and perform regular updates:"
echo "1. Define your github forked repository as origin"
echo "2. Define the original eudaq repository as upstream"
echo "3. Perform regularly to keep your repo updated:"
echo "4. git pull upstream"
echo "======================================================="
# Copying files for the TLU
tar xzf ${DOCKERDIR}/ZestSC1.tar.gz -C ${CODEDIR}/extern
tar xzf ${DOCKERDIR}/tlufirmware.tar.gz -C ${CODEDIR}/extern
fi
# 3. Fill the place-holders of the .templ-Dockerfile
# and .templ-docker-compose.yml and create the needed
# directories
DATADIR=${HOME}/eudaq_data/data
LOGSDIR=${HOME}/eudaq_data/logs
mkdir -p $DATADIR
mkdir -p $LOGSDIR
cd ${DOCKERDIR}
# -- copying relevant files
for dc in .templ-docker-compose.yml .templ-production.yml .templ-docker-compose.override.yml;
do
finalf=$(echo ${dc}|sed "s/.templ-//g")
cp $dc $finalf
sed -i "s#@CODEDIR#${CODEDIR}#g" $finalf
sed -i "s#@DATADIR#${DATADIR}#g" $finalf
sed -i "s#@LOGSDIR#${LOGSDIR}#g" $finalf
done
# 4. Create a .setupdone file with some info about the
# setup
cat << EOF > .setupdone
EUDAQ integration docker image and services
-------------------------------------------
Last setup performed at $(date)
DATA DIRECTORY: ${DATADIR}
LOGS DIRECTORY: ${LOGSDIR}
CODE DIRECTORY: ${CODEDIR}
EOF
cat .setupdone