Last active
January 30, 2020 11:33
-
-
Save pixmin/ad534c873e1bebc699ca81e47c764f59 to your computer and use it in GitHub Desktop.
Get a list of domains on a server
This file contains hidden or 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 | |
# From all the Apache sites-enabled conf files, | |
# extract the ServerAlias and ServerName lines. | |
# And for nginx too. | |
find /etc/apache2/sites-enabled/ -name "*.conf" -exec grep -E "ServerName|ServerAlias" {} \; \ | |
| grep -vE '^*\#' | sed -e 's/^[ \t]*//' | grep --color -E "^|ServerName|ServerAlias" \ | |
| awk {'print $2'} | sort | uniq | |
find /etc/nginx/sites-enabled/ -type l -exec grep -E "server_name" {} \; \ | |
| grep -vE '^*\#' | sed -e 's/^[ \t]*//' | grep --color -E "^|server_name" \ | |
| awk {'print $2'} | sort | uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment