-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade-pmwiki.sh
executable file
·59 lines (45 loc) · 1.71 KB
/
upgrade-pmwiki.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# XXX
# run as root
# TODO
#
# * only upgrade if newer version available
# maybe scrape http://www.pmwiki.org/wiki/PmWiki/Download
#
# * rewrite using perl
#
# * do something about "tar: write error" errors (which appear to be harmless)
WIKI_VERSION_URL='http://foo.com/wiki/pmwiki.php/SiteAdmin/Status'
# comment these out when live
RSYNC_DRYRUN='--dry-run'
RSYNC_VERBOSE='--verbose'
# the no- options are because the tarball owner/group is set from the source
# and will be retained if rsync'd.
RSYNC_OPTIONS='-a --no-owner --no-group'
UPGRADE_ROOT='/root/pmwiki'
BACKUP_ROOT='/var/local/backup'
WIKI_ROOT='/var/www/foo.com/web/wiki'
TDATE=$(date +%Y-%h-%d)
CVER=$(grep VersionNum $WIKI_ROOT/scripts/version.php)
echo "-- i have detected the installed version as [$CVER]"
echo "-- backing up wiki..."
tar -czf $BACKUP_ROOT/wiki-$TDATE.tar.gz $WIKI_ROOT
echo "-- downloading latest pmwiki..."
wget --directory-prefix=$UPGRADE_ROOT http://www.pmwiki.org/pub/pmwiki/pmwiki-latest.tgz
echo "-- extracting..."
tar -xzf $UPGRADE_ROOT/pmwiki-latest.tgz -C $UPGRADE_ROOT
# ugh - KLUDGE - better way? case for rewriting to perl?
LATEST_PMWIKI=$(tar -tzvf $UPGRADE_ROOT/pmwiki-latest.tgz | head -1 | cut -d' ' -f10)
echo "-- i have detected the latest version as [$LATEST_PMWIKI]"
echo "-- installing..."
rsync $RSYNC_OPTIONS $RSYNC_DRYRUN $RSYNC_VERBOSE \
$UPGRADE_ROOT/$LATEST_PMWIKI/ \
$WIKI_ROOT/
UVER=$(grep VersionNum $WIKI_ROOT/scripts/version.php)
echo "-- i have detected the installed version as [$UVER]"
echo "-- verify this by visiting: $WIKI_VERSION_URL"
echo "-- cleaning up..."
rm $UPGRADE_ROOT/pmwiki-latest.tgz
rm -rf $UPGRADE_ROOT/$LATEST_PMWIKI
#echo "delete this dir: [$UPGRADE_ROOT/$LATEST_PMWIKI]"
echo "-- done"