forked from mesocentre-mcia/mcia-irods-client-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcia-irods-client-install.sh
executable file
·333 lines (262 loc) · 8.3 KB
/
mcia-irods-client-install.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#! /bin/bash
# Configuration
PREFIX=/usr/local
IRODS_VERSION=3.3.1
MCIA_IRODS_UTILS_VERSION=0.7.9
GSI_BUILD=no
GLOBUS_MAJOR=5
GLOBUS_MINOR=0
GLOBUS_MICRO=4
KRB5_BUILD=no
# Parse command line
random_string_charlist () {
charlist=$1
tr -dc "$charlist" < /dev/urandom | head -c $2
}
random_filename() {
random_string_charlist "[:alnum:]" $1
}
BUILD_DIR=/tmp/`random_filename 12`
CLEANUP_BUILD_DIR=yes
while test $# -gt 0 ; do
arg=$1
shift
case $arg in
--irods-version)
IRODS_VERSION=$1
shift
;;
--build-dir)
BUILD_DIR=$1
shift
;;
--prefix)
PREFIX=$1
shift
;;
--debug)
echo debug mode
set -x
;;
--keep-build-dir)
CLEANUP_BUILD_DIR=no
;;
*)
;;
esac
done
# some functions
cleanup_build_dir() {
if test x$CLEANUP_BUILD_DIR = xyes ; then
rm -rf $BUILD_DIR
fi
}
check_ret() {
if test x$? != x0 ; then
cleanup_build_dir
exit -1
fi
}
# Do the job...
IRODS_TAR=irods-$IRODS_VERSION.tgz
IRODS_URL=https://github.com/irods/irods-legacy/archive/$IRODS_VERSION.tar.gz
# MCIA iRODS utilities
MCIA_IRODS_UTILS_URL=https://github.com/mesocentre-mcia/mcia-irods-utils/archive/$MCIA_IRODS_UTILS_VERSION.tar.gz
MCIA_IRODS_UTILS_BUILD=mcia-irods-utils-$MCIA_IRODS_UTILS_VERSION
MCIA_IRODS_UTILS_TAR=$MCIA_IRODS_UTILS_BUILD.tar.gz
# config GSI
GLOBUS_MM=$GLOBUS_MAJOR.$GLOBUS_MINOR
GLOBUS_VERSION=$GLOBUS_MM.$GLOBUS_MICRO
GLOBUS_FLAVOR=gcc64pthr
GLOBUS_INSTALLER=gt$GLOBUS_VERSION-all-source-installer
GLOBUS_TAR=$GLOBUS_INSTALLER.tar.bz2
GLOBUS_URL=http://www.globus.org/ftppub/gt$GLOBUS_MAJOR/$GLOBUS_MM/$GLOBUS_VERSION/installers/src/$GLOBUS_TAR
# config KERBEROS
KRB5_LOCATION=/usr
IRODS_HOME=$PREFIX/iRODS
IRODS_BINDIR=$IRODS_HOME/bin
IRODS_LIBDIR=$IRODS_HOME/lib
IRODS_DOCDIR=$IRODS_HOME/share/doc
IRODS_CLIENTS_BINDIR=$IRODS_HOME/clients/bin
IRODS_CLIENTS_LIBDIR=$IRODS_HOME/clients/lib
IRODS_CLIENTS_DOCDIR=$IRODS_HOME/clients/doc
GLOBUS_LOCATION=$BUILD_DIR/globus
mkdir -p $BUILD_DIR
if test x$? != x0 ; then
cleanup_build_dir
exit -1
fi
mkdir -p $PREFIX $IRODS_HOME $IRODS_BINDIR $IRODS_LIBDIR $IRODS_DOCDIR $IRODS_CLIENTS_BINDIR $IRODS_CLIENTS_LIBDIR $IRODS_CLIENTS_DOCDIR
check_ret
# download, compile and install Globus toolkit
if test x$GSI_BUILD = xyes -a ! -d $GLOBUS_LOCATION ; then
echo "download and install globus toolkit"
cd $BUILD_DIR
if test ! -d $GLOBUS_INSTALLER ; then
if test ! -f $GLOBUS_TAR ; then
wget $GLOBUS_URL
fi
tar xvfj $GLOBUS_TAR
fi
cd $GLOBUS_INSTALLER
./configure --prefix=$GLOBUS_LOCATION --with-flavor=$GLOBUS_FLAVOR
make globus-gsi && make install
check_ret
cd $GLOBUS_LOCATION
if test ! -d lib64 ; then
ln -s lib lib64
fi
fi
if test ! -d $BUILD_DIR/iRODS ; then
if test ! -f $BUILD_DIR/$IRODS_TAR ; then
wget --no-check-certificate $IRODS_URL -O $BUILD_DIR/$IRODS_TAR
fi
cd $BUILD_DIR
tar --strip-components=1 -xvf $BUILD_DIR/$IRODS_TAR
fi
cd $BUILD_DIR/iRODS
rm -f config/irods.config
# fix for irods3.0
mkdir -p installLogs
# fix for irods-3.0 3.1
for d in $/modules/*/microservices $BUILD_DIR/iRODS/lib/*/ $BUILD_DIR/iRODS/clients/*/ ; do
mkdir -p $d/obj
done
# client install
if test x$GSI_BUILD = xyes ; then
ENABLE_GSI="--enable-gsi --globus-location=$GLOBUS_LOCATION \
--gsi-install-type=$GLOBUS_FLAVOR"
fi
perl scripts/perl/configure.pl --enable-parallel --enable-file64bit \
$ENABLE_GSI
# propagate KRB5 values to config.mk, if needed
if test x$KRB5_BUILD = xyes ; then
sed -i -e "s/^#[ ]*KRB_AUTH[ ]*=[ ]*1$/KRB_AUTH = 1/g" -e "s/^KRB_LOC[ ]*=[ ]*.*/KRB_LOC=\/usr/g" config/config.mk
fi
pwd
CFLAGS="-fpermissive" make icommands GSI_SSL=ssl GSI_CRYPTO=crypto
check_ret
# move globus libraries to IRODS library path
if test x$GSI_BUILD = xyes ; then
cp -dp $GLOBUS_LOCATION/lib64/lib* $IRODS_CLIENTS_LIBDIR/
fi
# Copy copyright licenses and other files
cp -p COPYRIGHT/Copyright.txt $IRODS_DOCDIR/
cp -p COPYRIGHT/Copyright_Addendum.txt $IRODS_DOCDIR/
cp -p LICENSE.txt $IRODS_DOCDIR/
cp -p README.txt $IRODS_DOCDIR/
cp -p config/irods.config.template $IRODS_DOCDIR/
cp -p -R $BUILD_DIR/iRODS/clients/icommands/test/rules3.0 $IRODS_DOCDIR/examples-rules3.0
# copy icommands binaries
irodsClientCommands=`find $BUILD_DIR/iRODS/clients/icommands/bin/ -maxdepth 1 -executable -type f || find $BUILD_DIR/iRODS/clients/icommands/bin/ -maxdepth 1 -perm +111 -type f`
for binary in $irodsClientCommands ; do
cp -p $binary $IRODS_CLIENTS_BINDIR/
check_ret
done
# completion files
for f in $BUILD_DIR/iRODS/irods_completion.* ; do
cp -p $f $IRODS_CLIENTS_BINDIR/
done
# MCIA iRODS utils
if test ! -f $BUILD_DIR/$MCIA_IRODS_UTILS_TAR ; then
wget --no-check-certificate $MCIA_IRODS_UTILS_URL -O $BUILD_DIR/$MCIA_IRODS_UTILS_TAR
check_ret
fi
cd $BUILD_DIR
tar -xvf $BUILD_DIR/$MCIA_IRODS_UTILS_TAR
check_ret
cd $BUILD_DIR/$MCIA_IRODS_UTILS_BUILD
python setup.py install --prefix=$IRODS_HOME
cat > $PREFIX/init.bash <<EOF
#! /bin/bash
if test ! -d \$HOME/.irods ; then
mkdir -p \$HOME/.irods
fi
# iRODS client config file
envfile=\$HOME/.irods/.irodsEnv
if test ! -f \$envfile ; then
# create config file
echo "Creating iRODS configuration file."
icat=icat0.mcia.univ-bordeaux.fr
port=1247
zone=MCIA
username=\$USER
defaultresource=siterg-ubx
if test -n "\$PS1" ; then
echo "Please answer a few questions:"
read -e -p " - iCat host? " -i \$icat icat
read -e -p " - iRODS port? " -i \$port port
read -e -p " - iRODS zone? " -i \$zone zone
read -e -p " - User name? " -i \$username username
read -e -p " - Default resource? " -i \$defaultresource defaultresource
fi
cat > \$envfile << EOF2
# iRODS@MCIA
irodsHost '\$icat'
irodsPort \$port
irodsZone '\$zone'
irodsUserName '\$username'
irodsDefResource \$defaultresource
irodsAuthScheme password
irodsAuthFileName \$HOME/.irods/.irods-mcia
# mcia-irods-utils configuration
irodsRescList 'irule(mciaRGListWrite)'
irodsUseRescGroups true
EOF2
echo "iRODS configuration file \$envfile created"
else
echo "iRODS Configuration file \$envfile already configured"
fi
EOF
chmod a+x $PREFIX/init.bash
PYTHON_PKG_DIR_SUFFIX=$(python -c "import sys, os; print os.sep.join(['python' + sys.version[:3], 'site-packages'])")
IRODS_PYTHON_SITE_PKG_DIR=$IRODS_LIBDIR/$PYTHON_PKG_DIR_SUFFIX
cat > $PREFIX/bashrc <<EOF
#! /bin/bash
# iCommands environment
( echo \$PATH | grep -q $IRODS_CLIENTS_BINDIR ) || export PATH=$IRODS_BINDIR:$IRODS_CLIENTS_BINDIR:\$PATH
( echo \$LD_LIBRARY_PATH | grep -q $IRODS_CLIENTS_LIBDIR ) || export LD_LIBRARY_PATH=$IRODS_LIBDIR:$IRODS_CLIENTS_LIBDIR:\$LD_LIBRARY_PATH
( echo \$PYTHONPATH | grep -q $IRODS_PYTHON_SITE_PKG_DIR) || export PYTHONPATH=$IRODS_PYTHON_SITE_PKG_DIR:\$PYTHONPATH
# iCommands completion
[ -f $IRODS_CLIENTS_BINDIR/irods_completion.bash ] && source $IRODS_CLIENTS_BINDIR/irods_completion.bash
EOF
if test x$? != x0 ; then
cleanup_build_dir
exit -1
fi
chmod a+x $PREFIX/bashrc
if test x$? != x0 ; then
cleanup_build_dir
exit -1
fi
LOAD_GLOBUS_MODULE="# not needed"
if test "x$GSI_BUILD" = "xyes" ; then
LOAD_GLOBUS_MODULE="module load globus"
fi
cat > $PREFIX/modulefile <<EOF
#%Module -*- tcl -*-
##
## modulefile
##
proc ModulesHelp { } {
puts stderr "\tAdds iRODS clients to your environment variables,"
}
module-whatis "adds iRODS clients to your environment variables"
# load globus environment
$LOAD_GLOBUS_MODULE
set version $IRODS_VERSION
set root $PREFIX
set bindir \$root/iRODS/bin
set libdir \$root/iRODS/lib
set pypkgdir \$libdir/$PYTHON_PKG_DIR_SUFFIX
set clients_bindir \$root/iRODS/clients/bin
set clients_libdir \$root/iRODS/clients/lib
setenv IRODS_HOME \$root/iRODS
prepend-path PATH \$clients_bindir
prepend-path LD_LIBRARY_PATH \$clients_libdir
prepend-path PATH \$bindir
prepend-path LD_LIBRARY_PATH \$libdir
prepend-path PYTHONPATH \$pypkgdir
EOF
cleanup_build_dir
exit 0