-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathosg-build-shell
executable file
·59 lines (51 loc) · 1.19 KB
/
osg-build-shell
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
#!/bin/bash
# osg-build-shell
#
# Shell into the docker-osg-build container (if it's up)
CONTAINER_NAME=osg-build
u=
usage () {
{
echo "$(basename "$0") [-r|--root] [<command> [<arg>...]]"
echo
echo "Enters into the osg-build container to run a command."
echo "If the command is not specified, run bash."
echo "Runs the command as root if -r or --root is specified."
} >&2
}
case $1 in
-r|--root)
u=-u0
shift
;;
-h|--help)
usage
exit 0
;;
-*)
echo >&2 "Unknown option $1."
usage
exit 2
;;
esac
if [[ ! $1 ]]; then
command=bash
else
command=$1
shift
fi
# only allocate a tty if stdin and stdout are both ttys.
# Allocating a tty causes piping issues (for example, the output side
# will contain CRLF line terminators instead of LF)
t=
[[ -t 0 && -t 1 ]] && t=-t
docker=docker
if command -v podman &>/dev/null; then
docker=podman
fi
koji_hub_arg=
if [[ $KOJI_HUB ]]; then
koji_hub_arg=--env=KOJI_HUB=$KOJI_HUB
fi
$docker exec -i $t $u $koji_hub_arg $CONTAINER_NAME \
/usr/local/bin/command-wrapper.sh --no-strict-work-dir "$(pwd -P)" "$command" "$@"