don't use fully qualified name if a subdomain of $HOME/VHOST

This commit is contained in:
Eugene Ware
2013-07-08 21:12:37 +10:00
parent 3eadb0ae03
commit f4cdc94209

View File

@@ -3,7 +3,13 @@ set -e
APP="$1"; PORT="$2"
if [[ -f "$HOME/VHOST" ]]; then
[[ "$APP" == *.* ]] && hostname="${APP/\//-}" || hostname="${APP/\//-}.$(< "$HOME/VHOST")"
VHOST=$(< "$HOME/VHOST")
SUBDOMAIN=${APP/%\.${VHOST}/}
if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then
hostname="${APP/\//-}"
else
hostname="${APP/\//-}.$VHOST"
fi
cat<<EOF > $HOME/$APP/nginx.conf
upstream $APP { server 127.0.0.1:$PORT; }
server {