blob: 00bb0db738eb90dd2b6286fe8a1238dd0ddca407 (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
#!/bin/bash
#
# pmwiki management script.
#
SITES="<%= scope.lookupvar('pmwiki::sites_folder') %>"
BASE="<%= scope.lookupvar('pmwiki::www_folder') %>"
# Check for existing installations
function pmwiki_check_existing {
if [ -e "$BASE/pmwiki-$1" ]; then
echo "Folder $BASE/pmwiki-$1 already exists, skipping."
exit 1
fi
}
# Deploy a fresh pmwiki tree
function pmwiki_deploy {
if [ "$#" != "1" ]; then
new="`lynx -dump http://www.pmwiki.org/pub/pmwiki/ 2> /dev/null | grep ".tgz$" | grep -v latest | sed -e 's/^.*-//' | head -1`"
if [ -z "$new" ]; then
echo "Unable to determine latest release, please specify it manually:"
echo "Usage: `basename $0` deploy <version>"
else
new="`basename $new .tgz`"
fi
else
new="$1"
fi
# Setup
cd $BASE
pmwiki_check_existing $new
# Deploy a fresh pmwiki tree
wget http://pmwiki.org/pub/pmwiki/pmwiki-$new.tgz
wget http://pmwiki.org/pub/pmwiki/i18n/i18n-all.zip
tar zxvf pmwiki-$new.tgz && rm pmwiki-$new.tgz
( cd pmwiki-$new && unzip -o ../i18n-all.zip && rm $_ )
if [ ! -e "pmwiki-$new/index.php" ]; then
( cd pmwiki-$new && ln -s pmwiki.php index.php )
fi
chown -R root.root pmwiki-$new/
# Make initial symlink
if [ ! -e "wiki" ]; then
ln -s pmwiki-$new wiki
fi
}
# Upgrade a pmwiki instance using upstream source
function pmwiki_upgrade {
if [ "$#" != "2" ]; then
echo "Usage: `basename $0` upgrade <old_version> <new_version>"
exit 1
fi
# Setup
old="$1"
new="$2"
extra_folders=""
pmwiki_check_existing $new
cd $BASE
cp -a pmwiki-$old pmwiki-$old.backup
# Deploy a fresh pmwiki tree
pmwiki_deploy $new
# Copy files
for file in .htaccess index.php farmconfig.php local config.php wiki.d; do
if [ -e "pmwiki-$old/$file" ]; then
cp -a pmwiki-$old/$file pmwiki-$new/
fi
done
for extra_folder in $extra_folders; do
if [ -d ../pmwiki-$old/$extra_folder ]; then
cp -Rp ../pmwiki-$old/$extra_folder .
fi
done
# Themes and cookbook
rsync -av pmwiki-$old/cookbook/ pmwiki-$new/cookbook
rsync -av --exclude=pmwiki --exclude=print pmwiki-$old/pub/skins/ pmwiki-$new/pub/skins/
# Change symlink to point to the new location
cd $BASE ; rm -f wiki && ln -s pmwiki-$new wiki
# Done
echo "Audit: `du -hs pmwiki-$old`"
echo "Audit: `du -hs pmwiki-$new`"
echo "Check procedure and remove pmwiki-$old once you make sure that everything is fine."
}
# Install a pmwiki instance
function pmwiki_install {
local site="$1"
if [ -z "$site" ]; then
echo "Usage: `basename $0` install <name>"
exit 1
fi
if [ ! -d "$BASE/wiki" ]; then
echo "Please deploy pmwiki first"
exit 1
fi
if [ ! -d "$SITES/$site" ]; then
echo "Please configure site $site first"
exit 1
fi
if [ -e "$SITES/$site/wiki/field.php" ]; then
echo "Looks like $site wiki is already installed"
exit 1
fi
# Create folder structure
(
mkdir -p $SITES/$site/wiki/{local,uploads,wiki.d,cookbook}
cd $SITES/$site/wiki
ln -s field.php index.php
chown $site. wiki.d
touch local/config.php
chown root.$site local/config.php
)
# Setup dispatcher
echo '<?php include("/var/www/data/wiki/pmwiki.php"); ?>' > $SITES/$site/wiki/field.php
# Setup redirections
cat > $SITES/$site/wiki/.htaccess <<-EOF
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/?$ https://$site.<%= domain %>/Main/HomePage [R=permanent,QSA,L]
RewriteRule ^([^/a-z].*) field.php?n=\$1 [QSA,L]
EOF
# Setup config file
cat > $SITES/$site/wiki/local/config.php <<-EOF
<?php if (!defined('PmWiki')) exit();
\$ScriptUrl = "https://$site.<%= domain %>";
\$EnablePathInfo = 1;
EOF
}
# Main procedure
if [ -z "$1" ]; then
echo "Usage: `basename $0` <deploy|upgrade|install> [arguments]"
exit 1
elif [ "$1" == "deploy" ]; then
shift
pmwiki_deploy $*
elif [ "$1" == "upgrade" ]; then
shift
pmwiki_upgrade $*
elif [ "$1" == "install" ]; then
shift
pmwiki_install $*
fi
|