Skip to content

Instantly share code, notes, and snippets.

@trey
Created February 1, 2010 21:06
Show Gist options
  • Save trey/292032 to your computer and use it in GitHub Desktop.
Save trey/292032 to your computer and use it in GitHub Desktop.
Create a new project based on my site-template project.
#!/bin/sh
# Original script by Jason Tan: http://solutions.treypiepmeier.com/2009/03/03/virtual-hosts-on-osx-leopard/#comment-41787
DIR=/Users/$SUDO_USER/Sites/$1
if [[ ! -d $DIR && `id -u` -eq 0 ]]; then
echo ""
echo "Downloading site-template repository ..."
sudo -u $SUDO_USER git clone --quiet git://github.com/trey/site-template.git $DIR
cd $DIR
echo "Deleting unneeded parts ..."
rm -rf .git/
rm .gitignore
mv html5.html index.html
rm README.md
rm MIT-License.txt
VHOST=/etc/apache2/users/$SUDO_USER.conf
echo "<VirtualHost *:80>" >> $VHOST
echo "\tDocumentRoot \"$DIR\"" >> $VHOST
echo "\tServerName $1.dev" >> $VHOST
echo "</VirtualHost>\n" >> $VHOST
echo "VirtualHost created in $VHOST ..."
echo "127.0.0.1\t$1.dev" >> /etc/hosts
echo "/etc/host updated ..."
apachectl restart
mate $DIR
open http://$1.dev
echo ""
echo "Done!"
else
echo "usage: sudo treyvhost directory"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment