Skip to content

Instantly share code, notes, and snippets.

@dflynn15
Created June 16, 2014 21:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dflynn15/e4743e6d7ce360cd3fa6 to your computer and use it in GitHub Desktop.
Save dflynn15/e4743e6d7ce360cd3fa6 to your computer and use it in GitHub Desktop.
Fun bash script to write to XAMPP vhost and add symbolic link.
#!/bin/bash
# Format of command: ./xampp.sh new.website.name.com projectDir path/to/project/Dir
# Number of expected arguments
EXPECTED_ARGS=3
function create_symbolic_link {
sudo ln -s $1 /Applications/XAMPP/xamppfiles/htdocs/$2
}
function modify_vhosts {
sudo printf "\n<VirtualHost *:80 *:3002>\n\tDocumentRoot \"/Applications/XAMPP/xamppfiles/htdocs/$2\" \n\tServerName $1 \n</VirtualHost>" >> /Applications/XAMPP/etc/extra/httpd-vhosts.conf
}
clear
if [ $# -ne $EXPECTED_ARGS ]; then
echo "Inputed wrong number of arguments"
else
#Create symbolic link with second folder param
create_symbolic_link $3 $2
#Modify vhost file with given url
modify_vhosts $1 $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment