blob: 33d473c9b13ab0b554df3eae2e21b3d97cf7f3c9 (
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
|
#!/bin/bash
#
# wordpress management script.
#
BASE="<%= wordpress_folder %>"
LOCALE="<%= real_wordpress_locale %>"
# Set alternative base
function wordpress_set_base {
if [ ! -z "$1" ]; then
BASE="$1"
if [ ! -d "$BASE" ]; then
echo "No such folder $BASE"
exit 1
fi
fi
}
# Check for existing installations
function wordpress_check_existing {
if [ -e "$BASE/wordpress-$1" ]; then
echo "Folder $BASE/wordpress-$1 already exists, skipping."
exit 1
fi
}
# Deploy a fresh wordpress tree
function wordpress_deploy {
if [ "$#" != "1" ]; then
echo "Usage: `basename $0` deploy <version> [folder]"
exit 1
fi
# Setup
new="$1"
wordpress_set_base $2
wordpress_check_existing $new
# Deploy a fresh wordpress tree
cd $BASE
wget http://br.wordpress.org/wordpress-$new$LOCALE.zip
unzip wordpress-$new.zip && rm wordpress-$new.zip
chown -R root.root wordpress-$new/
}
# Upgrade a wordpress instance using upstream source.
function wordpress_upgrade {
if [ "$#" != "2" ]; then
echo "Usage: `basename $0` upgrade <old_version> <new_version> [folder]"
exit 1
fi
# Setup
old="$1"
new="$2"
extra_folders=""
wordpress_set_base $3
wordpress_check_existing $new
cd $BASE
cp -a wordpress-$old wordpress-$old.backup
# Deploy a fresh wordpress tree
wordpress_deploy $new
# Copy files
for file in .htaccess wp-config.php; do
if [ -e "wordpress-$old/$file" ]; then
cp -a wordpress-$old/$file wordpress-$new/
fi
done
for extra_folder in $extra_folders; do
if [ -d ../wordpress-$old/$extra_folder ]; then
cp -Rp ../wordpress-$old/$extra_folder .
fi
done
# Exclusions
exclude_plugins="--exclude=akismet --exclude=hello.php --exclude=index.php"
exclude_themes="--exclude=index.php --exclude=twentytwelve --exclude=twentyeleven --exclude=twentyten"
# Files, Plugins and Themes
rsync -av wordpress-$old/wp-content/blogs.dir/ wordpress-$new/wp-content/blogs.dir/
rsync -av $exclude_plugins wordpress-$old/wp-content/plugins/ wordpress-$new/wp-content/plugins/
rsync -av $exclude_themes wordpress-$old/wp-content/themes/ wordpress-$new/wp-content/themes/
# Fix permissions
chown -R root.root wordpress-$new/wp-content/{plugins,themes}
# Change symlink to point to the new location
#cd $BASE ; rm -f blogs && ln -s wordpress-$new blogs
# Done
echo "Audit: `du -hs wordpress-$old`"
echo "Audit: `du -hs wordpress-$new`"
echo "Check procedure and remove wordpress-$old once you make sure that everything is fine."
}
# Main procedure
if [ -z "$1" ]; then
echo "Usage: `basename $0` <deploy|upgrade> [arguments]"
exit 1
elif [ "$1" == "deploy" ]; then
shift
wordpress_deploy $*
elif [ "$1" == "upgrade" ]; then
shift
wordpress_upgrade $*
fi
|