added config-path option to setup.sh script (Closes: #698)

* added config-path option to setup.sh script
This commit is contained in:
17Halbe 2018-02-11 18:26:46 +01:00 committed by Johan Smits
parent 5394a505b9
commit 21b7cf72c9

View file

@ -11,6 +11,7 @@ INFO=$(docker ps \
IMAGE_NAME=$(echo $INFO | awk '{print $1}')
CONTAINER_NAME=$(echo $INFO | awk '{print $2}')
CONFIG_PATH="$(pwd)/config"
if [ -z "$IMAGE_NAME" ]; then
IMAGE_NAME=tvial/docker-mailserver:latest
@ -38,6 +39,8 @@ OPTIONS:
'tvial/docker-mailserver:latest'.
-c CONTAINER_NAME The name of the running container.
-p PATH config folder path (default: $(pwd)/config)
SUBCOMMANDS:
email:
@ -84,7 +87,7 @@ _docker_image() {
fi
docker run \
--rm \
-v "$(pwd)/config":/tmp/docker-mailserver \
-v "$CONFIG_PATH":/tmp/docker-mailserver \
-ti "$IMAGE_NAME" $@
}
@ -97,7 +100,7 @@ _docker_container() {
fi
}
while getopts ":c:i:" OPT; do
while getopts ":c:i:p:" OPT; do
case $OPT in
c)
CONTAINER_NAME="$OPTARG"
@ -105,6 +108,21 @@ while getopts ":c:i:" OPT; do
i)
IMAGE_NAME="$OPTARG"
;;
p)
case "$OPTARG" in
/*)
CONFIG_PATH="$OPTARG"
;;
*)
CONFIG_PATH="$(pwd)/$OPTARG"
;;
esac
if [ ! -d "$CONFIG_PATH" ]; then
echo "Directory doesn't exist"
_usage
exit 1
fi
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;