Last active
September 10, 2020 10:42
-
-
Save sandikata/3a7dbb88a2eecbf97d6e60ab9df331af to your computer and use it in GitHub Desktop.
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
#Nginx sed/grep variant | |
nginx -T | sed -r -e 's/[ \t]*$//' -e 's/^[ \t]*//' -e 's/^#.*$//' -e 's/[ \t]*#.*$//' -e '/^$/d' | \ | |
sed -e ':a;N;$!ba;s/\([^;\{\}]\)\n/\1 /g' | \ | |
grep -P 'server_name[ \t]' | grep -v '\$' | grep '\.' | \ | |
sed -r -e 's/(\S)[ \t]+(\S)/\1\n\2/g' -e 's/[\t ]//g' -e 's/;//' -e 's/server_name//' | \ | |
sort | uniq | xargs -L1 | |
#Nginx sed/perl variant | |
nginx -Tq | perl -ln0777e '$,=$\; s/^\s*#.*\n//mg; print grep !$u{$_}++ && !m/^_$/, map m/(\S+)/g, m/\bserver_name\s++(.*?)\s*;/sg' | |
#Named sed/grep | |
#1 variant | |
named-checkconf -z | sed "s/zone//;s/IN//;s/\///;s/loaded //" | |
#2 variant | |
named-checkconf -z | sed "s/zone//;s/IN//;s/://;s/loaded serial//;s#/##;s/[0-9]\+//g;" | |
#3 variant with *.arpa filter | |
named-checkconf -z | sed "s/zone//;s/IN//;s/://;s/..arpa//;s/loaded serial [0-9]+//;s#/##" | sed '/^[[:space:]]$/d' | |
# Apache sed/grep | |
httpd -D DUMP_VHOSTS | egrep "'default server'|alias" | sed "s/ /\n/g" | sed "s/alias//" | sed '/^$/d' | |
# second | |
apachectl -D DUMP_VHOSTS | cut -d ' ' -f13 | sort -u | grep -v '(.*)' | grep -v '^$' | |
# third | |
/usr/sbin/apache2ctl -S 2>&1 | awk '/namevhost/ {print $4;} ' | |
# this one may work , it's ugly but i cannot find a better solution. | |
httpd -S | egrep "'default server'|alias|namevhost" | sed "s/ /\n/g" | sed 's/(.*//' | egrep -v '(alias|namevhost|localhost|port|80|443)' | sed '/^$/d' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment