From ef650b0549eed5c471e71db172120025df9449f3 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sat, 16 Nov 2019 16:52:44 -0700 Subject: [PATCH] process volume mounts more efficiently --- ab-nginx.sh | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/ab-nginx.sh b/ab-nginx.sh index 24dccc2..9122ded 100755 --- a/ab-nginx.sh +++ b/ab-nginx.sh @@ -120,24 +120,19 @@ if [ "$WEBROOT_DIR" ]; then checkExist 'dir' "$WEBROOT_DIR" fi -# set up volume mounts for config, servers, webroot -if [ -z "$CONFIG_DIR" ] && [ -z "$WEBROOT_DIR" ] && [ -z "$SERVERS_DIR" ]; then - vmount="" -elif [ "$CONFIG_DIR" ] && [ "$WEBROOT_DIR" ] && [ "$SERVERS_DIR" ]; then - vmount="-v $CONFIG_DIR:/etc/nginx/config/ -v $SERVERS_DIR:/etc/nginx/sites/ -v $WEBROOT_DIR:/usr/share/nginx/html/" -elif [ "$CONFIG_DIR" ] && [ "$SERVERS_DIR" ]; then - vmount="-v $CONFIG_DIR:/etc/nginx/config/ -v $SERVERS_DIR:/etc/nginx/sites/" -elif [ "$CONFIG_DIR" ] && [ "$WEBROOT_DIR" ]; then - vmount="-v $CONFIG_DIR:/etc/nginx/config/ -v $WEBROOT_DIR:/usr/share/nginx/html/" -elif [ "$SERVERS_DIR" ] && [ "$WEBROOT_DIR" ]; then - vmount="-v $SERVERS_DIR:/etc/nginx/sites/ -v $WEBROOT_DIR:/usr/share/nginx/html/" -elif [ "$CONFIG_DIR" ]; then - vmount="-v $CONFIG_DIR:/etc/nginx/config/" -elif [ "$SERVERS_DIR" ]; then - vmount="-v $SERVERS_DIR:/etc/nginx/sites/" -elif [ "$WEBROOT_DIR" ]; then - vmount="-v $WEBROOT_DIR:/usr/share/nginx/html/" +# set up volume mounts +if [ "$CONFIG_DIR" ]; then + vmount="$vmount -v $CONFIG_DIR:/etc/nginx/config" fi +if [ "$SERVERS_DIR" ]; then + vmount="$vmount -v $SERVERS_DIR:/etc/nginx/sites" +fi +if [ "$WEBROOT_DIR" ]; then + vmount="$vmount -v $WEBROOT_DIR:/usr/share/nginx/html" +fi +# trim leading whitespace +vmount=${vmount##[[:space:]]} +echo "$vmount" # process startup parameters