Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
#!/bin/sh
#
# Example of automating the process of purging the HTTP proxy cache for
# a UT Web content site.
#
# This assumes:
#    * the script is running on the UT Web panel server
#    * The script is being run as the UT Web site account
#    * the URL to purge is the site's main URL (utwNNNNN.utweb.utexas.edu)
#    * all sub-URL's of the main site should be purged as well ($site/*)
#

siteuser=`whoami`
site=http://$siteuser.utweb.utexas.edu
urlstopurge="$site"

utweb_prod_balancers="
utweb-px-z1-p01.its.utexas.edu
utweb-px-z1-p02.its.utexas.edu
"
sitealiases=$(grep 'ServerAlias' /etc/httpd/vhost.d/`whoami`.utweb.utexas.edu.conf | cut -f 2 -d ' ' | grep -vP 'utw\d{5}' |xargs -0 |sort -u)

if  [ -z "$sitealiases" ] ; then
    echo "=== There are no domain aliases for this site account ==="
else echo === $sitealiases ===
fi

# Purge cache for utwNNNNN.utweb.utexas.edu hostname
for b in $utweb_prod_balancers; do
    id=`echo $b | sed s/.its.utexas.edu/_http/`
    for u in $urlstopurge ; do
    echo === $b $site
        curl -v \
        --cookie "balancer_id=$id" \
        -X PURGE \
        -D - "$u/*"
    done
done

# Purge cache for any additional hostnames
for b in $utweb_prod_balancers; do
    id=$(echo $b | sed s/.its.utexas.edu/_http/)
    for u in $sitealiases; do
    echo === $b $sitealiases
        curl -v \
        --cookie "balancer_id=$id" \
        -X PURGE \
        -D - "$u/*"
    done
done

...