This is a quick example how you can check the visibility of specific paths of multiple Magento instances with a shell script called checkr. For example:
- /var/log/system.log
- /var/log/exception.log
- /downloader/
- /var/
- /backup/
- /RELEASE_NOTES.txt
For security reasons, those folders or files should never visible or accessible from outside.
1. URLs
Create a simple list with your clients’ names and its URLs. Save this file as clients.list.
1 2 3 |
Cafe;http://www.cafe.com/ Lunch;http://www.lunch.com/ Pizza;http://www.pizza.de/ |
2. Shell Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#!/bin/sh # ========================================================================= # Title checkr.sh # Description Check the http response code of specific requests # Author Tobias Forkel # Date 2015/07/10 # Version 0.1 # Usage ./checkr.sh "/var/log/exception.log" # Notes # ========================================================================= if [[ -z $1 ]]; then echo 'Missing parameter. Example: ./checkr.sh "/var/log/system.log"' exit fi printf '%-20s %s\t %-20s %s\t %-20s %s\n' 'Name' 'Result' 'URL' while read ROW; do IFS=';' eval 'ROW=($ROW)' NAME=${ROW[0]} URL=${ROW[1]} # Set the request URL REQUEST=$(printf '%s%s' $URL $1) # Receive the http code from curl RESULT=$(curl -o /dev/null --silent --head --write-out '%{http_code}' $REQUEST) # Output a formatted row printf '%-20s %s\t %-20s %s\t %-20s %s\n' $NAME $RESULT $REQUEST done < clients.list |
3. Run
Run this script with a custom parameter.
1 |
./checkr.sh "/var/log/system.log" |
4. Results
1 2 3 4 |
Name Result URL Magento Commerce 404 http://www.magentocommerce.com/var/log/system.log Cafe 301 http://www.cafe.com/var/log/system.log Lunch 503 http://www.lunch.com/var/log/system.log |