-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
68 lines (64 loc) · 1.27 KB
/
run.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
#!/bin/bash
# Singularity App runscript
# Author: MB
# Date: 5.11.2019
#
# Executes either the app or the executable
#
usage(){
echo "Singularity Container"
if [[ -f /.singularity.d/runscript.help ]]; then
cat /.singularity.d/runscript.help
else
if [[ -f /etc/os-release ]]; then
echo $(grep PRETTY_NAME= /etc/os-release | sed 's/PRETTY_NAME=//')
elif [[ -f /etc/centos-release ]]; then
echo $(cat /etc/centos-release)
else
echo $(uname -a)
fi
fi
if [[ -d /scif/apps ]]; then
echo "SCIF (Apps): " $(ls /scif/apps)
fi
}
infos(){
if [[ -f /.singularity.d/labels.json ]]; then
python <<EOF
import json
data=json.loads(open('/.singularity.d/labels.json').read())
n=max(map(len, data.keys()))
format='%-'+str(n)+'s : %s'
for i in sorted(data.keys()):
print(format % (i,data[i]))
EOF
fi
}
if [ $# -gt 0 ]; then
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then
usage
exit
fi
if [[ "$1" == "--info" ]]; then
infos
exit
fi
if [[ -d /scif/apps ]]; then
echo $(ls /scif/apps) | grep $1 > /dev/null
if [ $? -eq 0 ]; then
name=$1
echo "Launching app: $name"
shift
exec /scif/apps/${name}/scif/runscript "$@"
else
echo "Executing: $@"
exec "$@"
fi
else
echo "Executing: $@"
exec "$@"
fi
else
usage
echo "Bye Bye"
fi