Skip to content

Instantly share code, notes, and snippets.

@marcw
Created December 25, 2010 19:31
Show Gist options
  • Save marcw/755014 to your computer and use it in GitHub Desktop.
Save marcw/755014 to your computer and use it in GitHub Desktop.
List vhost available on your machine and render it as an HTML5 document
#!/bin/bash
# Config
DIR="/opt/local/apache2/conf/sites-enabled"
# View
TITLE="local vhosts"
H1="vhosts on $HOSTNAME"
HEADER="<!DOCTYPE html>\n<html><head><title>$TITLE</title></head><body><h1>$H1</h1><ul>\n"
FOOTER="</ul><p>Generated at <time>`date +"%Y-%m-%d %H:%M"`</time></p></body></html>"
echo -e $HEADER
find $DIR -type l | xargs -L 1 \
awk '/ServerName/ {print "<li><a target=\"_blank\" href=\"http://"$2"\">"$2"</a></li>"}'
echo -e $FOOTER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment