-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.export.exec
95 lines (81 loc) · 2.98 KB
/
image.export.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
#!/bin/bash
#
# Copyright (c) 2017, SingularityWare, LLC. 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.
#
# This file also contains content that is covered under the LBNL/DOE/UC modified
# 3-clause BSD license and is subject to the license terms in the LICENSE-LBNL.md
# file found in the top-level directory of this distribution and at
# https://github.com/singularityware/singularity/blob/master/LICENSE-LBNL.md.
## 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
while true; do
case ${1:-} in
-h|--help|help)
exec "$SINGULARITY_libexecdir/singularity/cli/help.exec" "$SINGULARITY_COMMAND"
;;
-f|--file)
shift
SINGULARITY_EXPORT_FILE="${1:-}"
export SINGULARITY_EXPORT_FILE
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
SINGULARITY_IMAGE="${1:-}"
export SINGULARITY_IMAGE
shift
if [ -n "${1:-}" ]; then
SINGULARITY_EXPORT_FILE="${1:-}"
export SINGULARITY_EXPORT_FILE
shift
fi
if [ -z "${SINGULARITY_NOSUID:-}" -a -u "$SINGULARITY_libexecdir/singularity/bin/mount-suid" ]; then
exec "$SINGULARITY_libexecdir/singularity/bin/mount-suid" /bin/bash "$SINGULARITY_libexecdir/singularity/helpers/image.sh"
elif [ -x "$SINGULARITY_libexecdir/singularity/bin/mount" ]; then
exec "$SINGULARITY_libexecdir/singularity/bin/mount" /bin/bash "$SINGULARITY_libexecdir/singularity/helpers/image.sh"
else
message ERROR "Could not locate the Singularity binary: $SINGULARITY_libexecdir/singularity/bin/mount\n"
exit 1
fi
message ERROR "We should never have gotten here..."
exit 1