From 8665803253aa331abddfe78c9490361c50d8b1d6 Mon Sep 17 00:00:00 2001 From: omarc1492 <10967529+omarc1492@users.noreply.github.com> Date: Fri, 30 Oct 2020 10:43:31 -0500 Subject: [PATCH] Update setup.sh Add script options -z and -Z to handle SELinux environments. --- setup.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index cf322e50..19ee2604 100755 --- a/setup.sh +++ b/setup.sh @@ -27,7 +27,7 @@ function _unset_vars { unset CDIR CRI INFO IMAGE_NAME CONTAINER_NAME DEFAULT_CONFIG_PATH unset USE_CONTAINER WISHED_CONFIG_PATH CONFIG_PATH VOLUME USE_TTY - unset SCRIPT + unset SCRIPT USING_SELINUX } function _get_current_directory @@ -55,6 +55,7 @@ WISHED_CONFIG_PATH= CONFIG_PATH= VOLUME= USE_TTY= +USING_SELINUX= function _check_root { @@ -116,6 +117,14 @@ OPTIONS: -h Show this help dialogue + -z Allow container access to the bind mount content + that is shared among multiple containers + on a SELinux-enabled host. + + -Z Allow container access to the bind mount content + that is private and unshared with other containers + on a SELinux-enabled host. + SUBCOMMANDS: email: @@ -184,7 +193,7 @@ function _docker_image fi ${CRI} run --rm \ - -v "${CONFIG_PATH}":/tmp/docker-mailserver \ + -v "${CONFIG_PATH}":/tmp/docker-mailserver"${USING_SELINUX}" \ "${USE_TTY}" "${IMAGE_NAME}" "${@}" fi } @@ -240,7 +249,7 @@ function _main fi local OPTIND - while getopts ":c:i:p:h" OPT + while getopts ":c:i:p:hzZ" OPT do case ${OPT} in c) CONTAINER_NAME="${OPTARG}" ; USE_CONTAINER=true ;; # container specified, connect to running instance @@ -259,6 +268,8 @@ function _main fi ;; h) _usage ; return ;; + z) USING_SELINUX=":z" ;; + Z) USING_SELINUX=":Z" ;; *) echo "Invalid option: -${OPTARG}" >&2 ;; esac done