Hello , welcome to Castle-Murray
Login Register

sean has made 10 posts.

host file L:1 | C:2
Date posted: Jan. 5, 2024, 2:38 p.m.
Problem: need host file
What does it do?: Generates a host file entry for all domains on the server
sean@castle-murray.com[~/bash/awk/cpanel] #
awk -F ": " -v host=$(hostname -i) '!/*/ {print host " " $1 " www." $1 }' /etc/userdomains
Running out of space? L:0 | C:0
Date posted: Nov. 1, 2023, 4:36 p.m.
Problem: Running out of space
What does it do?: Finds large error logs in the /home/ dir.
sean@castle-murray.com[~//bash/awk] #
find /home -not -path "/home/virtfs/*" -type f -size +1G -exec du -h {} + |sort -rh |  awk -F "G" '/error.log$/ {print $0; sum+=$1;} END{print "Total: " sum}'
Status code check L:1 | C:2
Date posted: Feb. 20, 2023, 4:25 a.m.
Problem: customer says "all my sites are down" but doesn't give an example
What does it do?: Checks the http status code of all sites confirmed pointing at this server by IP address
sean@castle-murray.com[~/bash/cpanel] #
(
IPS=$(hostname -I | sed '$s/.$//' | tr ' ' '|')
domains=$(awk -F ": " '!/*/ {system("echo -e " $1 " $(dig +short " $1 ")")}' /etc/userdomains)
echo "Domains that are pointed here:"
echo "$domains" | grep  -E "$IPS"| awk '{system("echo -e " $0 " $(timeout 3 curl -s -A 'STATUS-TEST' -o /dev/null -w '%{http_code}' https://" $1"); echo")}' | column -t
echo
echo "domains not pointed here"
echo "$domains" | grep -v  -E "$IPS" | awk '{print $1}'
)
Is it pointed here? L:0 | C:0
Date posted: Feb. 7, 2023, 8:14 p.m.
Problem: not sure if domains are pointed here? This will list all domains and subdomains which are indeed pointed at this server. add a -v to the grep for domains NOT pointed here.
What does it do?: Validates if a domain is pointed at any IP on the server
sean@castle-murray.com[~/bash/cpanel] #
awk -F ": " '!/*/ {system("echo " $1 " $(dig +short " $1 ")")}' /etc/userdomains | grep -E "$(hostname -I | sed '$s/.$//' | tr ' ' '|')"
Reverse Docroot L:1 | C:1
Date posted: Nov. 30, 2022, 3:49 a.m.
Problem: Need to know what domain points to the directory you're currently in without having to figure out what domains to look for?
What does it do?: Tells you the domain of the co
sean@castle-murray.com[~/bash/uapi/imh] #
for i in $(uapi DomainInfo list_domains | awk '/-|main_domain/  {print $2}' ); do echo " $i $(docroot.py $i)"| grep $(pwd); done
1 Next Last