forked from apptainer/singularity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.exec
112 lines (95 loc) · 3.46 KB
/
check.exec
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
#!/bin/bash
#
# Copyright (c) 2017, SingularityWare, LLC. All rights reserved.
# Copyright (c) 2017, Vanessa Sochat. All rights reserved.
#
# See the COPYRIGHT.md file at the top-level directory of this distribution and at
# https://github.com/singularityware/singularity/blob/master/COPYRIGHT.md.
#
# This file is part of the Singularity Linux container project. It is subject to the license
# terms in the LICENSE.md file found in the top-level directory of this distribution and
# at https://github.com/singularityware/singularity/blob/master/LICENSE.md. No part
# of Singularity, including this file, may be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE.md file.
## Basic sanity
if [ -z "$SINGULARITY_libexecdir" ]; then
echo "Could not identify the Singularity libexecdir."
exit 1
fi
## Load functions
if [ -f "$SINGULARITY_libexecdir/singularity/functions" ]; then
. "$SINGULARITY_libexecdir/singularity/functions"
else
echo "Error loading functions: $SINGULARITY_libexecdir/singularity/functions"
exit 1
fi
# If no arguments
# default SINGULARITY_CHECKLEVEL is highest (3)
# define check tags to be default
SINGULARITY_CHECKLEVEL=3 # LOW
SINGULARITY_CHECKTAGS="default"
while true; do
case ${1:-} in
-h|--help|help)
exec "$SINGULARITY_libexecdir/singularity/cli/help.exec" "$SINGULARITY_COMMAND"
;;
-l|--low) # levels 3,2,1
SINGULARITY_CHECKLEVEL=3 # LOW
shift;
;;
-m|--med|--medium) # levels 2,1
SINGULARITY_CHECKLEVEL=2 # MED
shift;
;;
--high)
SINGULARITY_CHECKLEVEL=1 # level 1 only
shift; # HIGH
;;
-t|--tag)
shift;
SINGULARITY_CHECKTAGS="${1:-}"
echo $SINGULARITY_CHECKTAGS
shift;
;;
-*)
message ERROR "Unknown option: ${1:-}\n"
exit 1
;;
*)
break
;;
esac
done
if [ -f "$SINGULARITY_libexecdir/singularity/cli/$SINGULARITY_COMMAND.info" ]; then
. "$SINGULARITY_libexecdir/singularity/cli/$SINGULARITY_COMMAND.info"
else
message ERROR "Could not find the info file for: $SINGULARITY_COMMAND\n"
ABORT 255
fi
if [ -z "${1:-}" ]; then
if [ -n "${USAGE:-}" ]; then
echo "USAGE: $USAGE"
else
echo "To see usage summary type: singularity help $SINGULARITY_COMMAND"
fi
exit 0
fi
RETVAL=0
SINGULARITY_IMAGE="${1:-}"
# We will inspect the image by mounting it, and this should also work for
# bootstrap since we will have the SINGULARITY_ROOTFS
SINGULARITY_MOUNTPOINT=`mktemp -d /tmp/.singularity-check.XXXXXXXX`
export SINGULARITY_IMAGE SINGULARITY_MOUNTPOINT SINGULARITY_CHECKLEVEL SINGULARITY_CHECKTAGS
shift
if [ -z "${SINGULARITY_NOSUID:-}" -a -u "$SINGULARITY_libexecdir/singularity/bin/mount-suid" ]; then
eval "$SINGULARITY_libexecdir/singularity/bin/mount-suid" /bin/bash "$SINGULARITY_libexecdir/singularity/helpers/check.sh"
RETVAL=$?
elif [ -x "$SINGULARITY_libexecdir/singularity/bin/mount" ]; then
eval "$SINGULARITY_libexecdir/singularity/bin/mount" /bin/bash "$SINGULARITY_libexecdir/singularity/helpers/check.sh"
RETVAL=$?
else
message ERROR "Could not locate the Singularity binary: $SINGULARITY_libexecdir/singularity/bin/mount\n"
exit 1
fi
rmdir "$SINGULARITY_MOUNTPOINT"
exit $RETVAL