Created
February 2, 2016 16:26
-
-
Save edwardgalligan/7865dba609161d21a0a6 to your computer and use it in GitHub Desktop.
Generates /etc/hosts entries from Apache vhosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
# Usage: | |
# generaate-hosts.sh 127.0.0.1 | |
# | |
# Generates: | |
# 127.0.0.1 vhost1.domain | |
# 127.0.0.1 vhost1.domainalias1 | |
# etc. | |
## | |
if [ "$1" == "" ]; then | |
echo "Please specify an IP for your hosts file entries" | |
exit 1 | |
fi | |
cat ./*.conf | grep 'ServerAlias\|ServerName' | sed 's/Server\(Name\|Alias\)//g ; s/^ *//g ; s/ *$//g' | tr '\n' ' ' | sed "s/^/ /g ; s/ \$//g ; s/ \\([^ ]*\\)/$1 \\1\\n/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment