-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.sh
More file actions
executable file
·45 lines (38 loc) · 999 Bytes
/
docker.sh
File metadata and controls
executable file
·45 lines (38 loc) · 999 Bytes
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
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# (c) Axians IT Security GmbH
# Jürgen Mang <juergen.mang@sec.axians.de>
# https://www.axians.de/security
# https://github.com/AxiansITSecurity/Restsh
ACTION="$1"
shift 1
if [ -z "$RESTSH_CONFIG_PATH" ]
then
echo "Environment variable RESTSH_CONFIG_PATH not set."
exit 1
fi
SELINUX_STATUS=$(getenforce 2>/dev/null)
if [ "$SELINUX_STATUS" = "Enforcing" ]
then
VOLUME_OPTS=":Z"
else
VOLUME_OPTS=""
fi
DOCKER_OPTS=("run" "--rm" "-it" "-v" "${RESTSH_CONFIG_PATH}:/restsh-config${VOLUME_OPTS}" "--network" "host")
case "$ACTION" in
build)
docker build --no-cache -t restsh .
;;
run)
docker ${DOCKER_OPTS[@]} restsh "$@"
;;
setup)
docker ${DOCKER_OPTS[@]} --entrypoint /restsh/restsh/restsh.setup restsh "$@"
;;
*)
echo "Runs restsh in a container."
echo "Usage: $(basename "$0") <build|setup|run>"
exit 2
;;
esac
exit 0