forked from cyclone-project/usecases-hackathon-2016
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcluster_install.sh
625 lines (535 loc) · 19.5 KB
/
cluster_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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
source /scripts/toolshed/os_detection.sh
check_if_vpn_or_not()
{
component_vpn_name=${component_vpn_name:-vpn}
ss-display "test if deployment" 1>/dev/null 2>/dev/null
ret=$?
if [ $ret -ne 0 ]; then
export USER_NEW=${USER_NEW:-ifbuser}
export IP_PARAMETER=${IP_PARAMETER:-hostname}
else
check_vpn=$(ss-get ss:groups | grep -c ":$component_vpn_name")
category=$(ss-get ss:category)
if [ "$check_vpn" != "0" ]; then
if [ "$category" == "Deployment" ]; then
vpn_multiplicity=$(ss-get $component_vpn_name:multiplicity)
if [ "$vpn_multiplicity" != "0" ]; then
USER_NEW=${USER_NEW:-ifbuser}
if [ "$(echo $(ss-get net.services.enable) | grep '"vpn"' | wc -l)" == "1" ]; then
IP_PARAMETER=vpn.address
ss-set net.services.enable "[\"vpn\"]"
else
ss-set net.services.enable "[]"
IP_PARAMETER=hostname
fi
else
USER_NEW=${USER_NEW:-ifbuser}
ss-set net.services.enable "[]"
IP_PARAMETER=hostname
fi
else
USER_NEW=${USER_NEW:-ifbuser}
ss-set net.services.enable "[]"
IP_PARAMETER=hostname
fi
else
USER_NEW=${USER_NEW:-ifbuser}
IP_PARAMETER=hostname
fi
fi
#url.service display when vpn is on
if [ $IP_PARAMETER == "vpn.address" ]; then
#MASTER_IP=$(ss-get $MASTER_HOSTNAME:$IP_PARAMETER)
IP_VPN=$(ss-get $component_vpn_name:hostname)
url="ssh://$USER_NEW@$IP_VPN"
#ss-set url.ssh "${url}"
ss-set url.service "${url}"
ss-set ss:url.service "${url}"
fi
WORKDIR=/root/mydisk
mkdir -p $WORKDIR
chmod 750 /root
chmod 775 $WORKDIR
}
initiate_master_cluster()
{
check_if_vpn_or_not
user_add
user_sudoers
ID=1
HOSTIP=$(ss-get $IP_PARAMETER)
if [ "$category" == "Deployment" ]; then
ss-set master.nodename $(ss-get nodename)
HOSTNAME=$(ss-get nodename)-$ID
ss-get --timeout=3600 slave.nodename
SLAVE_NAME=$(ss-get slave.nodename)
else
HOSTNAME=machine-$ID
fi
ssh_root=/root/.ssh
ssh_user=/home/$USER_NEW/.ssh
if [ ! -f $ssh_user/authorized_keys ]; then
mkdir -p $ssh_user
touch $ssh_user/authorized_keys
chmod 700 $ssh_user
chmod 600 $ssh_user/authorized_keys
chown $USER_NEW:$USER_NEW $ssh_user/authorized_keys
fi
cat $ssh_root/authorized_keys >> $ssh_user/authorized_keys
msg_info "ssh key of root imported to $USER_NEW."
HOSTNAME=$(echo $HOSTNAME | sed "s|_|-|g")
echo "$HOSTNAME" > /etc/hostname
hostname $HOSTNAME
}
initiate_slave_cluster()
{
check_if_vpn_or_not
user_add
user_sudoers
ID=1
if [ "$category" != "Deployment" ]; then
ss-abort "You need to deploy with a master!!!"
fi
ss-set slave.nodename $(ss-get nodename)
SLAVE_HOSTNAME=$(ss-get nodename).$(ss-get id)
SLAVE_HOSTNAME_SAFE=$(ss-get nodename)-$(ss-get id)
SLAVE_IP=$(ss-get $SLAVE_HOSTNAME:$IP_PARAMETER)
ss-get --timeout=3600 master.nodename
MASTER_HOSTNAME=$(ss-get master.nodename)
MASTER_HOSTNAME_SAFE=$MASTER_HOSTNAME-$ID
MASTER_IP=$(ss-get $MASTER_HOSTNAME:$IP_PARAMETER)
SLAVE_HOSTNAME_SAFE=$(echo $SLAVE_HOSTNAME_SAFE | sed "s|_|-|g")
echo "$SLAVE_HOSTNAME_SAFE" > /etc/hostname
hostname $SLAVE_HOSTNAME_SAFE
}
initiate_install_edugain()
{
apt-get install -y python python-dev python-pip libpam-python
pip install scriptine
pip install requests[security]
wget -O - https://raw.githubusercontent.com/cyclone-project/cyclone-python-pam/master/setup.sh | sed 's/~/\/tmp\//g' | sh
wget -O /lib/security/cyclone_pam.py https://raw.githubusercontent.com/bryan-brancotte/cyclone-python-pam/patch-5/lib/security/cyclone_pam.py
echo "{
\"ports\":[[20000, 25000] ]
}" > /lib/security/cyclone_config
cp /etc/pam.d/sshd /etc/pam.d/sshd.bak
cat /etc/pam.d/sshd.bak | sed 's/ auth /auth /g' | sed 's/auth /#auth /g' | sed 's/##auth /auth /g' > /etc/pam.d/sshd
service ssh restart
}
initiate_install_edugain_ubuntu16()
{
#apt-get install -y python python-dev python-pip libpam-python
# Toogle to install xPra
#export XPRA_INSTALL=true
## INSTALL CYCLONE PAM
wget -O - https://raw.githubusercontent.com/cyclone-project/cyclone-python-pam/V2/setup.sh | sh > /root/cyclone-install.log
#sed -ie '/BASE_URI =/i\
#global s\
#s = socket\.socket(socket\.AF_INET, socket\.SOCK_DGRAM)\
#s\.connect(("8\.8\.8\.8", 80))\
#' /usr/local/bin/cyclone_pam.py
# sed -i 's|host_ip = .*|host_ip = s\.getsockname()[0]|' /usr/local/bin/cyclone_pam.py
# Load default configuration
echo "# CUSTOM NUVLA CONFIGURATION" >> /etc/cyclone/cyclone.conf
echo "OIDC_HOST = https://federation.cyclone-project.eu" >> /etc/cyclone/cyclone.conf
echo "PORTS = 20000-25000" >> /etc/cyclone/cyclone.conf
if [ "$(echo $(ss-get cloudservice) | grep exoscale | wc -l)" == "1" ]; then
EXO_HOSTNAME=$(ss-get hostname)
echo "HOSTNAME_OPENSTACK = $EXO_HOSTNAME" >> /etc/cyclone/cyclone.conf
elif [ "$(ss-get cloudservice)" == "ifb-genouest-genostack" ]; then
echo "HOSTNAME_OPENSTACK = http://169.254.169.254/latest/meta-data/local-ipv4" >> /etc/cyclone/cyclone.conf
elif [ "$(ss-get cloudservice)" == "cyclone-fr2" ]; then
echo "HOSTNAME_OPENSTACK = http://169.254.169.254/latest/meta-data/local-ipv4" >> /etc/cyclone/cyclone.conf
else
echo "HOSTNAME_OPENSTACK = http://169.254.169.254/latest/meta-data/public-ipv4" >> /etc/cyclone/cyclone.conf
fi
# Clean up installation files
#cd ~ && rm -rf cyclone-pam
}
install_edugain_ubuntu16()
{
EDUGAIN_OTHERS_USERS=$(ss-get edugain.others.users)
if [ -z "$EDUGAIN_OTHERS_USERS" -o $( echo "$EDUGAIN_OTHERS_USERS" | grep -c "@") == 0 ]; then
msg_info "No new user to add in federation proxy Eudgain ."
else
# Set good syntax
others=$(echo ", $EDUGAIN_OTHERS_USERS" | sed -e 's/[^ ],/ ,/' -e 's/,[^ ]/, /' )
fi
if [ "$(echo $(ss-get cloudservice) | grep exoscale | wc -l)" == "1" ]; then
OPENSTACK_HOSTNAME=$(ss-get hostname)
elif [ "$(ss-get cloudservice)" == "ifb-genouest-genostack" ]; then
OPENSTACK_HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
elif [ "$(ss-get cloudservice)" == "cyclone-fr2" ]; then
OPENSTACK_HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
else
OPENSTACK_HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
fi
echo "REALM = $(ss-get federated_identity_realm)" >> /etc/cyclone/cyclone.conf
echo "CLIENT_ID = $(ss-get federated_identity_client_id)" >> /etc/cyclone/cyclone.conf
echo "CLIENT_SECRET = $(ss-get federated_identity_client_secret)" >> /etc/cyclone/cyclone.conf
if [ ! "$OPENSTACK_HOSTNAME" == "" ]; then
echo "HOSTNAME = $OPENSTACK_HOSTNAME" >> /etc/cyclone/cyclone.conf
fi
cd /scripts/
NEW_USER="$(ss-get edugain_username)"
source /scripts/edugain_access_tool_shed.sh --dry-run
source /scripts/allows_other_to_access_me.sh --dry-run
auto_gen_users
gen_key_for_user $NEW_USER
echo "EMAIL = $(echo_owner_email) $others" > /home/$NEW_USER/.cyclone
publish_pubkey
allow_others
source /scripts/populate_hosts_with_components_name_and_ips.sh --dry-run
component_vpn_name=${component_vpn_name:-vpn}
check_vpn=$(ss-get ss:groups | grep -c ":$component_vpn_name")
if [ "$check_vpn" != "0" ]; then
if [ "$category" == "Deployment" ]; then
if [ "$(echo $(ss-get net.services.enable) | grep vpn | wc -l)" == "1" ]; then
populate_hosts_with_components_name_and_ips vpn.address
else
populate_hosts_with_components_name_and_ips hostname
fi
else
populate_hosts_with_components_name_and_ips hostname
fi
else
populate_hosts_with_components_name_and_ips hostname
fi
if [ "$(ss-get cloudservice)" == "cyclone-fr2" ]; then
# set the service url to SSH url
url=$(echo -n "$(ss-get url.ssh)" | sed 's/root/ubuntu/g')
ss-set url.ssh "${url}"
ss-set url.service "${url}"
ss-set ss:url.service "${url}"
fi
url="ssh://$NEW_USER@$(ss-get hostname)"
old_ssh="$(ss-get url.ssh)"
ss-set url.ssh "${url}"
ss-set url.service "[ssh-edu]${url}, ${old_ssh}"
ss-set ss:url.service "[ssh-edu]${url}, ${old_ssh}"
# Execute rc.local for the first time manually
/etc/rc.local
}
install_edugain()
{
source /scripts/edugain_access_tool_shed.sh --dry-run
source /scripts/allows_other_to_access_me.sh --dry-run
#auto_gen_users
gen_key_for_user $USER_NEW
init_edugain_acces_to_user $USER_NEW
add_email_for_edugain_acces_to_user $(echo_owner_email) $USER_NEW
#publish_pubkey
#allow_others
#source /scripts/populate_hosts_with_components_name_and_ips.sh --dry-run
#populate_hosts_with_components_name_and_ips $IP_PARAMETER
service ssh restart
#echo $(hostname -I | sed 's/ /\n/g' | head -n 1) > /etc/hostname
#hostname -F /etc/hostname
url="ssh://$USER_NEW@$(ss-get hostname)"
ss-set url.ssh "${url}"
ss-set url.service "${url}"
ss-set ss:url.service "${url}"
echo "FederatedEntryPoint overlay deploy done"
}
msg_info()
{
ss-display "test if deployment" 1>/dev/null 2>/dev/null
ret=$?
if [ $ret -ne 0 ]; then
echo -e "$@"
else
echo -e "$@"
ss-display "$@"
fi
}
install_federation_proxy()
{
msg_info "Extract username and usermail"
EDUGAIN_OTHERS_USERS=$(ss-get edugain.others.users)
username=$(cat /opt/slipstream/client/bin/slipstream.context | grep username | sed 's/username = //g')
cat /opt/slipstream/client/bin/slipstream.context | grep cookie | sed 's/cookie = //g' > /root/.slipstream-cookie
ss-user-get $username 1> /root/user.xml
user_mail=$(cat /root/user.xml | sed 's/ /\n/g' | grep email= | sed 's/email=//g' | sed 's/"//g')
ss-display "$username has mail $user_mail"
ss-set user.mail.edugain $user_mail
if [ -z "$EDUGAIN_OTHERS_USERS" -o $( echo "$EDUGAIN_OTHERS_USERS" | grep -c "@") == 0 ]; then
msg_info "No new user to add in federation proxy Edugain ."
else
# Set good syntax
others=$(echo ", $EDUGAIN_OTHERS_USERS" | sed -e 's/[^ ],/ ,/' -e 's/,[^ ]/, /' )
fi
if [ ! -d /ifb/federated-filtering-proxy-with-docker/ ]
then
mkdir -p /ifb/federated-filtering-proxy-with-docker/
cd /ifb/federated-filtering-proxy-with-docker/
git clone https://github.com/cyclone-project/federated-filtering-proxy-with-docker .
echo "cyclone: $user_mail $others" > apache_groups
# iptables -I INPUT 1 -p tcp -i docker0 -m tcp --dport 8080 -j ACCEPT
msg_info "docker proxy ready to start"
chmod a+rx *.sh
fi
msg_info "run federated proxy"
cd /ifb/federated-filtering-proxy-with-docker/
./startFilteringProxy.sh | tee /var/log/run_federate_proxy.log
}
user_add()
{
getent passwd $USER_NEW > /dev/null
user_missing=$?
if [ "$user_missing" != "0" ]; then
useradd --create-home -u 666 $USER_NEW --shell /bin/bash
else
usermod -u 666 $USER_NEW
groupmod -g 666 $USER_NEW
fi
ln -s /root/mydisk/ /home/$USER_NEW/work
usermod -aG root $USER_NEW
msg_info ""
msg_info "$USER_NEW created for launch job"
}
user_sudoers(){
if grep -q $USER_NEW "/etc/sudoers"; then
echo "$USER_NEW ready"
else
echo -e "$USER_NEW\tALL=(ALL)\tNOPASSWD:ALL" >> /etc/sudoers
fi
}
selinux_config(){
setenforce 1
setsebool -P use_nfs_home_dirs=true
}
check_ip()
{
NETWORK_MODE=$(ss-get network)
if [ "$NETWORK_MODE" == "Public" ]; then
PUBLIC_IP=$(ss-get $IP_PARAMETER)
#ss-set hostname "${PRIVATE_IP}"
HOSTIP=$(echo $(hostname -I | sed 's/ /\n/g' | head -n 1))
SLAVE_IP=$HOSTIP
sed -i "s|$PUBLIC_IP|$HOSTIP|g" /etc/hosts
else
PUBLIC_IP=$(ss-get $IP_PARAMETER)
HOSTIP=$(ss-get $IP_PARAMETER)
SLAVE_IP=$HOSTIP
fi
ss-set ip.ready "$HOSTIP"
}
check_ip_slave_for_master()
{
url="ssh://$USER_NEW@$PUBLIC_IP"
ss-set url.service "${url}"
ss-set ss:url.service "${url}"
for (( i=1; i <= $(ss-get $SLAVE_NAME:multiplicity); i++ )); do
msg_info "Waiting ip of slave to be ready."
ss-get --timeout=3600 $SLAVE_NAME.$i:ip.ready
PUBLIC_SLAVE_IP=$(ss-get $SLAVE_NAME.$i:$IP_PARAMETER)
SLAVE_IP=$(ss-get $SLAVE_NAME.$i:ip.ready)
sed -i "s|$PUBLIC_SLAVE_IP|$SLAVE_IP|g" /etc/hosts
done
}
check_ip_master_for_slave()
{
msg_info "Waiting ip of master to be ready."
ss-get --timeout=3600 $MASTER_HOSTNAME:ip.ready
url=$(ss-get $MASTER_HOSTNAME:url.service)
PUBLIC_IP_MASTER=$(ss-get $MASTER_HOSTNAME:$IP_PARAMETER)
MASTER_IP=$(ss-get $MASTER_HOSTNAME:ip.ready)
sed -i "s|$PUBLIC_IP_MASTER|$MASTER_IP|g" /etc/hosts
ss-set url.service "${url}"
ss-set ss:url.service "${url}"
}
#####
# NFS
#####
NFS_start()
{
msg_info "Starting NFS..."
if iscentos 7; then
systemctl enable nfs-server
systemctl start nfs-server
systemctl reload nfs-server
elif iscentos 6; then
chkconfig nfs on
service nfs start
service nfs reload
fi
if isubuntu; then
service nfs-kernel-server start
service nfs-kernel-server reload
fi
exportfs -av
ss-set nfs.ready "true"
msg_info "NFS is started."
}
NFS_ready(){
ss-get --timeout=3600 $MASTER_HOSTNAME:nfs.ready
nfs_ready=$(ss-get $MASTER_HOSTNAME:nfs.ready)
msg_info "Waiting NFS to be ready."
while [ "$nfs_ready" == "false" ]
do
sleep 10;
nfs_ready=$(ss-get $MASTER_HOSTNAME:nfs.ready)
done
}
# exporting NFS share from master
NFS_export()
{
# Pas de paramètre
if [[ $# -lt 1 ]]; then
echo "This function expects a directory in argument !"
else
EXPORT_DIR=$1
if [ ! -d "$EXPORT_DIR" ]; then
msg_info "$EXPORT_DIR doesn't exist !"
else
msg_info "Exporting NFS share of $EXPORT_DIR..."
EXPORTS_FILE=/etc/exports
if grep -q --perl-regex "$EXPORT_DIR\t" $EXPORTS_FILE; then
echo "$EXPORT_DIR ready"
else
echo -ne "$EXPORT_DIR\t" >> $EXPORTS_FILE
fi
for (( i=1; i <= $(ss-get $SLAVE_NAME:multiplicity); i++ )); do
if [ $IP_PARAMETER == "hostname" ]; then
node_host=$(ss-get $SLAVE_NAME.$i:ip.ready)
else
node_host=$(ss-get $SLAVE_NAME.$i:$IP_PARAMETER)
fi
if grep -q $EXPORT_DIR.*$node_host $EXPORTS_FILE; then
echo "$node_host ready"
else
echo -ne "$node_host(rw,sync,no_subtree_check,no_root_squash) " >> $EXPORTS_FILE
fi
done
echo "" >> $EXPORTS_FILE # last for a newline
msg_info "$EXPORT_DIR is exported."
fi
fi
}
# Mounting directory
NFS_mount()
{
# Pas de paramètre
if [[ $# -lt 1 ]]; then
echo "This function expects a directory in argument !"
else
MOUNT_DIR=$1
if [ ! -d "$MOUNT_DIR" ]; then
msg_info "$MOUNT_DIR doesn't exist !"
else
msg_info "Mounting $MOUNT_DIR..."
umount $MOUNT_DIR
mount $MASTER_IP:$MOUNT_DIR $MOUNT_DIR 2>/tmp/mount_error_message.txt
ret=$?
msg_info "$(cat /tmp/mount_error_message.txt)"
if [ $ret -ne 0 ]; then
ss-abort "$(cat /tmp/mount_error_message.txt)"
else
msg_info "$MOUNT_DIR is mounted"
fi
fi
fi
}
## ADD SLAVES
UNSET_parameters(){
ss-set nfs.ready "false"
ss-set sge.ready "false"
}
NFS_export_add()
{
# Pas de paramètre
if [[ $# -lt 1 ]]; then
echo "This function expects a directory in argument !"
else
EXPORT_DIR=$1
if [ ! -d "$EXPORT_DIR" ]; then
msg_info "$EXPORT_DIR doesn't exist !"
else
msg_info "Exporting NFS share of $EXPORT_DIR..."
EXPORTS_FILE=/etc/exports
if grep -q --perl-regex "$EXPORT_DIR\t" $EXPORTS_FILE; then
echo "$EXPORT_DIR ready"
else
echo -ne "$EXPORT_DIR\t" >> $EXPORTS_FILE
echo -ne "$SLAVE_IP(rw,sync,no_subtree_check,no_root_squash) " >> $EXPORTS_FILE
echo "" >> $EXPORTS_FILE # last for a newline
fi
if grep -q $EXPORT_DIR.*$SLAVE_IP $EXPORTS_FILE; then
echo "$SLAVE_IP ready"
else
WD=$(echo $EXPORT_DIR | sed 's|\/|\\\/|g')
sed -i '/'$WD'/s/$/\t'$SLAVE_IP'(rw,sync,no_subtree_check,no_root_squash)/' $EXPORTS_FILE
fi
msg_info "$EXPORT_DIR is exported."
fi
fi
}
make_file_test_sge()
{
# Pas de paramètre
if [[ $# -lt 1 ]]; then
echo "This function expects a directory in argument !"
else
TESTDIR=$1
mkdir -p $TESTDIR
chmod 775 $TESTDIR
echo "for i in {1..50}" > $TESTDIR/qsub_test.sh
echo " do" >> $TESTDIR/qsub_test.sh
echo " len=\$(shuf -i 1-10 -n 1)" >> $TESTDIR/qsub_test.sh
echo " echo \"sleep \$len\" > /tmp/sleep\$i-\$len.sh" >> $TESTDIR/qsub_test.sh
echo " qsub /tmp/sleep\$i-\$len.sh" >> $TESTDIR/qsub_test.sh
echo "done" >> $TESTDIR/qsub_test.sh
echo "echo \"run 'watch -n 1 qstat -f' to monitor the computation\"" >> $TESTDIR/qsub_test.sh
chmod 755 $TESTDIR/qsub_test.sh
fi
}
make_file_test_slurm()
{
# Pas de paramètre
if [[ $# -lt 1 ]]; then
echo "This function expects a directory in argument !"
else
file_name=submit
TESTDIR=$1
mkdir -p $TESTDIR
chmod 775 $TESTDIR
echo "#!/bin/bash" > $TESTDIR/$file_name.sh
echo "#" >> $TESTDIR/$file_name.sh
echo "#SBATCH --output=res.txt" >> $TESTDIR/$file_name.sh
echo "for i in {1..50}" >> $TESTDIR/$file_name.sh
echo " do" >> $TESTDIR/$file_name.sh
echo " len=\$(shuf -i 1-10 -n 1)" >> $TESTDIR/$file_name.sh
echo " echo \"#\$i : sleep \$len\" >> res.txt" >> $TESTDIR/$file_name.sh
echo " srun sleep \$len" >> $TESTDIR/$file_name.sh
echo "done" >> $TESTDIR/$file_name.sh
echo "wait" >> $TESTDIR/$file_name.sh
chmod 755 $TESTDIR/$file_name.sh
fi
}
clean_docker()
{
apt-get purge -y docker*
apt-get autoremove -y --purge docker*
apt-get autoclean
rm -rf /var/lib/docker
rm /etc/apparmor.d/docker
if grep -q docker /etc/group
then
groupdel docker
else
echo "group not exits"
fi
}
post_install_edugain(){
if isubuntu; then
check_if_vpn_or_not
if [ $IP_PARAMETER == "hostname" ]; then
pip install -r /scripts/requirements.txt
if isubuntu 14; then
initiate_install_edugain
elif isubuntu 16; then
initiate_install_edugain_ubuntu16
fi
fi
fi
}