-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp_update.sh
More file actions
executable file
·40 lines (34 loc) · 834 Bytes
/
wp_update.sh
File metadata and controls
executable file
·40 lines (34 loc) · 834 Bytes
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
#!/bin/bash
update_wp (){
current=$1
url=$2
# create tmp dir and download latest version
mkdir tmp
curl -O https://wordpress.org/latest.tar.gz
tar -zxf latest.tar.gz -C tmp/
new='tmp/wordpress'
rm -fr $new/wp-content
oU=`stat -c "%U" $current`
oG=`stat -c "%G" $current`
if [ -e "$current/wp-config.php" ]; then
for f in $( ls $new ) ; do
if [ -e "$current/$f" ]; then
rm -fr "$current/$f"
cp -ar "$new/$f" "$current/$f"
fi
done
else
echo -e "This is not a wordpress directory"
fi
rm -fr tmp latest.tar.gz
chown -R $oU:$oG $current
if [ -e /usr/bin/links ]; then
links -dump "http://$url/wp-admin/upgrade.php?step=1&backto=%2Fwp-admin%2F"
fi
}
if [ -z $1 && -z $2 ]; then
echo -e "$0 /blog/root/dir fqdn \n"
exit
else
update_wp $1 $2
fi