Nginx Vhost / generate_vhost

Jon Langevin f26e375 

Jon Langevin b11899d 

Jon Langevin f26e375 










Jon Langevin 50245a7 
Jon Langevin f26e375 










Jon Langevin b11899d 


Jon Langevin f26e375 


#!/bin/bash
set -e
VHOSTDIR=/var/www
VHOSTSKEL=/var/www/.skel/vhost-default

echo -e "Specify the vhost domain name:"
read VHOST

if [ "$VHOST" = "" ] ; then
	echo "Invalid domain!"
	exit 1;
fi

echo "\nYou typed: $VHOST \n"

IP=`ifconfig | grep 'inet addr:'| grep -v ':127.*' | grep -v ':192.*' | grep -v ':10.*' | cut -d: -f2 | awk '{ print $1}'`;

echo -e "Specify the vhost IP from the list of available Public IPs:\n$IP"
read VHOSTIP

if [ "$VHOSTIP" = "" ] ; then
        echo "Invalid IP!"
        exit 1;
fi

echo "\nYou typed: $VHOSTIP \n"

VHOSTPATH="$VHOSTDIR/$VHOST"
sudo -u www-data cp -Rf "$VHOSTSKEL/" "$VHOSTPATH"
sudo -u www-data ack-grep -l VHOSTDIR $VHOSTPATH/conf/* | xargs -t -n 1 sed -i -e "s/VHOSTDIR/$VHOSTDIR/g"
sudo -u www-data ack-grep -l DOMAIN $VHOSTPATH/conf/* | xargs -t -n 1 sed -i -e "s/DOMAIN/$VHOST/g"
sudo -u www-data ack-grep -l SERVERIP $VHOSTPATH/conf/* | xargs -t -n 1 sed -i -e "s/SERVERIP/$VHOSTIP/g"
echo "Skeleton copied to \"$VHOSTPATH\""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.