Last active
December 18, 2015 22:58
-
-
Save stansidel/5857747 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
#!/bin/bash | |
_file=$(mktemp -t "check_robots_internal_XXXXXX") | |
find /www/ -maxdepth 2 -name robots.txt | xargs grep "^[^#]*Disallow: /\s*$" -L > $_file | |
# First, try to copy the default robots.txt to all the dirs missing it | |
find /www/ -mindepth 1 -maxdepth 1 -type d '!' -exec test -e "{}/robots.txt" ';' -print0 | xargs -0 -I target_folder cp /www/0default/robots.txt target_fo | |
# If it somehow failed for some of the folders, then report | |
find /www/ -mindepth 1 -maxdepth 1 -type d '!' -exec test -e "{}/robots.txt" ';' -print >> $_file | |
if [ -s "$_file" ] | |
then | |
mails=`cat /www/sitechecker/mails4internal.txt` | |
# Send it to email | |
/bin/mail -s "There are incorrect robots.txt on the server!" "$mails" < $_file | |
fi | |
rm $_file |
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
[email protected] [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment