Skip to content

Instantly share code, notes, and snippets.

@lloydwatkin
Last active August 29, 2015 14:07
Show Gist options
  • Save lloydwatkin/1d6c9e3e19a2fa707a0b to your computer and use it in GitHub Desktop.
Save lloydwatkin/1d6c9e3e19a2fa707a0b to your computer and use it in GitHub Desktop.
Split arguments up for vhost substitution
#! /bin/bash
#
# - For example:
#
# VHOSTS="xmpp.surevine.com|locahost:3000|websocket;stats.surevine.com|localhost:8080" ./splitter.sh
#
VHOST_SEPARATOR=";"
PARAM_SEPARATOR="|"
echo "Processing: $VHOSTS"
vhosts=$(echo $VHOSTS | tr $VHOST_SEPARATOR "\n")
for vhost in $vhosts
do
IFS="$PARAM_SEPARATOR" read -a params <<< "$vhost"
domain="${params[0]}"
proxy="${params[1]}"
conf="${params[2]}"
if [ -z "$conf" ]; then
conf="default"
fi
echo -e "\n$domain \n======================\n\
Proxy :\t $proxy\n\
Conf :\t $conf"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment