-
Notifications
You must be signed in to change notification settings - Fork 13
/
Singularity
216 lines (158 loc) · 6.29 KB
/
Singularity
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
Bootstrap: docker
From: ubuntu:latest
%labels
MAINTAINER hamid.arabnejad@gmail.com
%help
This Singularity container makes your life easier by installing all the necessary required packages for fabsim3 program.
See https://github.com/djgroen/FabSim3.git for more information
How it works !!!, just run :)
./fabsim.simg --help
OR
./fabsim.simg -h
%post
echo "export fabsim_repo=https://github.com/djgroen/FabSim3.git" >> $SINGULARITY_ENVIRONMENT
# Installing required packages
apt-get update
apt-get install -y --no-install-recommends openjdk-8-jdk git ant subversion wget gnupg python3-pip python3-dev openssh-server rsync
apt-get purge -y openjdk-11*
# Installing EGI certificates
wget -q -O - https://dist.eugridpma.info/distribution/igtf/current/GPG-KEY-EUGridPMA-RPM-3 | apt-key add -
echo "#### EGI Trust Anchor Distribution ####" >> /etc/apt/sources.list && \
echo "deb http://repository.egi.eu/sw/production/cas/1/current egi-igtf core" >> /etc/apt/sources.list
apt-get update
apt-get install -y ca-policy-egi-core
# setting up python and installing packages
cd /usr/local/bin
ln -s /usr/bin/python3 python
pip3 install --upgrade pip
pip install -U pip setuptools
pip install pyyaml numpy fabric3 cryptography==2.4.2
pip install easyvvuq muscle3
# clean up
rm -rf /var/lib/apt/lists/*
# Installing QCG client
SVN=https://apps.man.poznan.pl/svn/qcg-broker/branches/vecma/
SVN_USER=piontek
SVN_PASSWD=piontek
mkdir -p /QCG-client
svn co --username ${SVN_USER} --password ${SVN_PASSWD} --non-interactive ${SVN} /QCG-client/source
ant -f /QCG-client/source/build.xml client-rebuild
rm -r -f /QCG-client/build
ant -f /QCG-client/source/build.xml -Ddeploy.dir=/QCG-client/build deploy-client-single-dir
rm -r -f /QCG-client/source
# To save help files
mkdir /fabsim_container_files
#-----------------------------------------------------------------
# runscript.help
#
cat << EOF_HELP > /fabsim_container_files/runscript.help
How to use FabSim3 singularity image :)
USAGE:
./fabsim.simg [option]
OPTIONS:
-h|--help print container help
-i|--install [PATH] install fabsim3 in in your local machine
by default, it will be downloaded in sub-folder ./FabSim3 in your current directory
you also can set the installation directory by setting PATH parameter
EOF_HELP
#-----------------------------------------------------------------
# fabsim_env.conf
#
cat << EOF_FabSim_ENV > /fabsim_container_files/fabsim_env.conf
#export PYTHONPATH=\${fabsim_INSTALL_DIR}:\$PYTHONPATH
export fabsim_INSTALL_DIR=\${fabsim_INSTALL_DIR}
alias fab="\$PWD/fabsim.simg"
EOF_FabSim_ENV
#-----------------------------------------------------------------
# make the setup_fabsim_env file
#
cat << EOF_setup_fabsim_env > /fabsim_container_files/setup_fabsim_env
please add/load the generated fabsim_env.conf in your ~/.bashrc
To load:
$ source \${fabsim_INSTALL_DIR}/fabsim_env.conf
To add to your ~/.bashrc
$ echo \"source \${fabsim_INSTALL_DIR}/fabsim_env.conf\" >> ~/.bashrc
$ source ~/.bashrc
EOF_setup_fabsim_env
#-----------------------------------------------------------------
# fabsim_env_warning
#
cat << EOF_fabsim_env_warning > /fabsim_container_files/fabsim_env_warning
environment variable \$fabsim_INSTALL_DIR is empty !!!
1) Please make sure you install fabsim by
$ ./fabsim.simg -i [preferred install directory]
or
$ ./fabsim.simg --install [preferred install directory]
OR
2) if you did the previous step,
please go <fabsim_INSTALL_DIR> and add/load the generated fabsim_env.conf in your ~/.bashrc
To load:
$ source <fabsim_INSTALL_DIR>/fabsim_env.conf
To add to your ~/.bashrc
$ echo "source <fabsim_INSTALL_DIR>/fabsim_env.conf" >> ~/.bashrc
$ source ~/.bashrc
NOTE: In all cases, <fabsim_INSTALL_DIR> should be replaced
by your local fabsim installation directory
EOF_fabsim_env_warning
%environment
export QCG_ENV_CONFIGURATION_FILE=/QCG-client/build/etc/qcg-broker-client.conf
export QCG_ENV_CLIENT_LOCATION_DEFAULT=/QCG-client/build
export PATH=/QCG-client/build/bin/:${PATH}
export QCG_ENV_URL=httpg://broker.plgrid.qcg.psnc.pl:8443/qcg/services/
export QCG_ENV_DN=/C=PL/O=GRID/O=PSNC/CN=qcg-broker/broker.plgrid.qcg.psnc.pl
export QCG_ENV_CERTIFICATES=/etc/grid-security/certificates
export QCG_ENV_GFTP_HOSTNAME=eagle.man.poznan.pl
%runscript
#-----------------------------------------------------------------
# $ ./fabsim.simg
# $ ./fabsim.simg -h
# $ ./fabsim.simg --help
#
if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
cat /fabsim_container_files/runscript.help
return 0
fi
#-----------------------------------------------------------------
# $ ./fabsim.simg -i [PATH]
# $ ./fabsim.simg --install [PATH]
#
if [ "$1" = "-i" ] || [ "$1" = "--install" ]; then
echo "Installing FabSim3 . . ."
if [ -z "$2" ]; then
fabsim_INSTALL_DIR=$PWD
else
fabsim_INSTALL_DIR="$2"
fi
fabsim_INSTALL_DIR=${fabsim_INSTALL_DIR}/FabSim3
echo "fabsim_INSTALL_DIR = "$fabsim_INSTALL_DIR
#-- clone FabSim3 github repository
mkdir -p ${fabsim_INSTALL_DIR}
git clone ${fabsim_repo} ${fabsim_INSTALL_DIR}
#-- generate machines_user.yml file
if [ ! -f ${fabsim_INSTALL_DIR}/deploy/machines_user.yml ]; then
cp ${fabsim_INSTALL_DIR}/deploy/machines_user_example.yml ${fabsim_INSTALL_DIR}/deploy/machines_user.yml
sed -i "s/your-username/`whoami`/g;s#~/FabSim3#${fabsim_INSTALL_DIR}#g" ${fabsim_INSTALL_DIR}/deploy/machines_user.yml
fi
id
#-- create fabsim_env file to be added inside ~/.bashrc
echo "$(eval "echo \"$(cat /fabsim_container_files/fabsim_env.conf)\"")" > ${fabsim_INSTALL_DIR}/fabsim_env.conf
echo "$(eval "echo \"$(cat /fabsim_container_files/setup_fabsim_env)\"")"
return 0
fi
#-----------------------------------------------------------------
# check if FabSim is installed or NOT
# before executing any additional command
# $ ./fabsim.simg ...
echo "args :" "$@"
echo "fabsim_INSTALL_DIR -> " $fabsim_INSTALL_DIR
if [ -z "$fabsim_INSTALL_DIR" ]; then
cat /fabsim_container_files/fabsim_env_warning
return 0
fi
old_PATH="$PWD"
cd $fabsim_INSTALL_DIR
pwd
echo "RUNNING : fab " "$@"
echo ""
fab "$@"
cd "$old_PATH"