Welcome to my Blog!
Information should be free, accurate, and available. I will be updating this section most often, enjoy!
Various galleries of artwork and photography I have done over the last five years.
Mini scripts I have written and decided to share. Mostly oneliners for managing network and system load.
Software projects are in the works and will be here eventually!
You can contact me through various methods.
Lets make short time of it. I'll just put the script and then the output.
For parsing a list of sites and displays their respective DocumentRoot.
USER=webuser;
for i in `grep $USER /etc/userdomains | cut -d":" -f1`;
do s=$(grep -niC3 \ $i /usr/local/apache/conf/httpd.conf|grep DocumentRoot \
|awk '{ print $3}');
printf "%-30s" ${i} " - "${s}; printf "\n";
doneAnd the output:
mindbend.org - /home/webuser/public_html/mindbend.org wiredgoat.com - /home/webuser/public_html/wiredgoat.com oddsmojo.com - /home/webuser/public_html/oddsmojo.com
Reasons for needing this can vary, but having it is essential for routinely modifying a large amount of sites.
For creating a list of sites owned by every user owned by one owner. Essentially, if you have a series of cpanel accounts owned by one WHM user, this pulls all of the sites hosted under the WHM user.
OWNER=webuser
for i in `grep -li owner=${OWNER} /var/cpanel/users/*`;
do grep $i /etc/userdomains | cut -d":" -f1;
doneThe output will look something like:
mindbend.org oddsmojo.com wiredgoat.com wirelesspeg.com servicepeg.com
Very useful for quickly identifying sites under one owner.
Lets assume the output above was placed into a file called sites. We now have a dilemma, sites were imported but some are not showing up yet, some are showing the holding page. We suspect DNS issues. This method for determining propagation and DNS is a little flawwed as the length of items inside Virtual entries in your httpd.conf file can vary. Play with this but note that you may need to increase or decrease the grep depth. First thing to do is create a list of the sites and their existing IP and their expected IP.
for i in `cat sites`;
do s=$(dig $i a +short);
t=$(grep -niB3 \ $i /usr/local/apache/conf/httpd.conf \
|grep Virt|awk '{ print $2}'|sed 's/>//' \
|cut -d":" -f1);
echo $i " h: " $s " a: " $t;
doneOutput will look something similar to:
mindbend.org h: 174.143.253.175 a: 174.143.253.175 wiredgoat.com h: 174.143.253.175 a: 174.143.253.175 oddsmojo.com h: 68.178.232.100 a: 68.178.232.100
As you can see, the IP addresses match. But what if you have a list of over 100 domains and some do not match? Let us assume the output from above is kept in a file called sites:
for i in `cat sites`;
do echo $i | awk -F" " '{ if ($3 != $5) print $1 " " $3 "--" $5 }';
doneIf the script finds any hosts that do not match, output will look like:
faildomain.net 127.0.0.1 -- 0.0.0.0
Once you have this list, you can do the needful with various other scripts to parse through.
I am available for consultation should the need for custom scripts arrise. Please do not hestitate to email me for a quote.
|
|
There are so many things that sound obscene in the field of topology.
-- Ari Nieh