forked from NeuroDesk/neurocommand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
containers.sh
executable file
·88 lines (79 loc) · 2.7 KB
/
containers.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
#!/bin/bash
if [[ -z "$1" ]] || [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo "Shows or installs available Neurodesk containers"
echo
echo "Usage:"
echo " $0 all # Shows all available Neurodesk containers"
echo " $0 --all # Installs all available Neurodesk containers"
echo " $0 PATTERN # Shows all containers that match PATTERN"
echo " $0 --PATTERN # Installs all containers that match PATTERN"
echo
echo "Examples:"
echo " $0 all"
echo " $0 diffusion"
echo " $0 --bidscoin"
echo
exit 1
fi
_script="$(readlink -f ${BASH_SOURCE[0]})" ## who am i? ##
_base="$(dirname $_script)" ## Delete last component from $_script ##
source neurodesk/configparser.sh ${_base}/config.ini
install="false"
pattern=$1
if [ ${1:0:2} = '--' ]; then
install="true"
pattern=${1:2}
fi
echo "--------------------------------------"
if [ "$install" = "true" ]; then
echo "Installing *${pattern}* containers"
else
echo "To install ALL containers, run:"
echo "$0 --all"
echo "--------------------------------------"
echo "To install individual containers, run:"
fi
echo "--------------------------------------"
echo
while read appsh; do
arrayIn=(${appsh//_/ })
if [ "$pattern" != "all" ] && [[ ${arrayIn[0]} != *${pattern}* ]]; then
continue
fi
appcat=${arrayIn[@]:3}
appcat_clean=${appcat:11:-1}
apphead="| ${arrayIn[0]} | ${arrayIn[1]} | ${arrayIn[2]} | ${appcat_clean} | Run:"
appfetch="./local/fetch_containers.sh ${arrayIn[0]} ${arrayIn[1]} ${arrayIn[2]}"
eval $(echo printf '"%.0s-"' {1..${#apphead}})
echo
echo $apphead
eval $(echo printf '"%.0s-"' {1..${#apphead}})
echo
echo $appfetch
echo
if [ "$install" = "true" ]; then
eval $appfetch
err=$?
if [ $err -eq 0 ] ; then
installmsg="| SUCCESS | ${arrayIn[0]} ${arrayIn[1]} ${arrayIn[2]} | $(date)"
eval $(echo printf '"%.0s-"' {1..${#installmsg}})
echo
echo $installmsg
eval $(echo printf '"%.0s-"' {1..${#installmsg}})
echo
echo
echo
else
installmsg="| FAILED | ${arrayIn[0]} ${arrayIn[1]} ${arrayIn[2]} | $(date)"
eval $(echo printf '"%.0s-"' {1..${#installmsg}})
echo
echo $installmsg
eval $(echo printf '"%.0s-"' {1..${#installmsg}})
echo
echo
echo "Existing due to install error(s) ..."
echo
exit
fi
fi
done < cvmfs/log.txt