2 # mwpurgecache - invalidate mediawiki cache
10 echo "$PROG $VER - invalidate mediawiki cache
11 Copyright (c) 2005 Claudio Jolowicz <claudio@jolowicz.com>
13 Copying and distribution of this file, with or without modification,
14 are permitted in any medium without royalty provided the copyright
15 notice and this notice are preserved. This programs comes with
16 ABSOLUTELY NO WARRANTEE.
22 echo "Syntax: $PROG [options] [--] [pages]
26 -H, --host host name (default: localhost)
27 -w, --wiki WIKI server path to wiki (default: /wiki/)
28 -u, --user USER username for HTTP authentication
29 -p, --passwd PASS password for HTTP authentication
30 -d, --dryrun show commands without executing them
31 -q, --quiet quiet (no output)
32 -v, --verbose be verbose (print server response)
33 -h, --help display this message
34 -V, --version display version information
36 Options and arguments must be separated by whitespace. WIKI must
37 match wgArticlePath, such that \$wgArticlePath = \"WIKI/\$1\". WIKI
38 must not contain regex special characters.
40 This script requests all wiki pages listed on the command line by
41 HTTP, prefixed by the wiki path, appending \`?action=purge' to the
42 URL. If no pages are specified, it retrieves the list of all pages
43 from Special:Allpages.
47 \$ $PROG Main_page Help:Contents
48 \$ $PROG -H wiki.my.org -w /mediawiki -u joe -p banana
49 \$ $PROG -H wiki.my.org --dryrun | wc -l
53 ## The '-e#' is a noop option to avoid `Unsupported scheme' errors.
60 opt_host
=http
://localhost
70 -H|
--host) opt_host
="$2"; shift;;
71 -w|
--wiki) opt_wiki
="$2"; shift;;
72 -u|
--user) opt_user
="$2"; shift;;
73 -p|
--passwd) opt_passwd
="$2"; shift;;
74 -d|
--dryrun) opt_dryrun
=true
;;
75 -q|
--quiet) opt_quiet
=true
;;
76 -v|
--verbose) opt_verbose
=true
;;
77 -h|
--help) usage
; exit 0;;
78 -V|
--version) version
; exit 0;;
80 -*) usage
2>&1; exit 1;;
85 opt_host
=${opt_host%/}
86 opt_wiki
=/${opt_wiki#/}
87 opt_wiki
=${opt_wiki%/}/
88 [ x
"$opt_user" = x
"" ] || user
="--http-user=${opt_user}"
89 [ x
"$opt_passwd" = x
"" ] || passwd
="--http-passwd=${opt_passwd}"
90 $opt_dryrun && run
=echo
91 $opt_verbose && verbose
="--server-response"
92 $opt_quiet && quiet
="-q"
95 wget
-qO- "$user" "$passwd" "${opt_host}${opt_wiki}Special:Allpages" |
96 sed -re '/start content/,/end content/p' -e 's/href="([^"]+)"/\nGREPME:\1\n/g' |
97 sed -nre 's/^GREPME:(.*)$/\1/p' |
100 for page
; do echo "${opt_wiki}${page}"; done
105 $run wget
-O/dev
/null
"$user" "$passwd" "$quiet" "$verbose" "${opt_host}${page}?action=purge"