-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpupdate.sh
More file actions
executable file
·41 lines (33 loc) · 842 Bytes
/
wpupdate.sh
File metadata and controls
executable file
·41 lines (33 loc) · 842 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
#!/usr/bin/env bash
set -e
if [[ $EUID -ne "0" ]]; then
echo "This utility needs root privileges to modify content in /var/www"
exit 1
fi
# Update all WordPress sites in /var/www, accounting for special directories
update_site() {
wpcmd="wp --allow-root"
if [ -z $1 ]; then
echo "No directory specified to upgrade"
return 1
fi
pushd $1 || return 2
sudo $wpcmd core update && sudo $wpcmd theme update-all && sudo $wpcmd plugin update-all
popd
return 0
}
if [[ ! -z $1 ]]; then
update_site $1
exit 0
fi
possible_dirs=`find /var/www -mindepth 1 -maxdepth 1 -type d`
for dir in $possible_dirs; do
if [[ -f "$dir/wp-config.php" ]]; then
update_site $dir
elif [[ -f "$dir/blog/wp-config.php" ]]; then
update_site "$dir/blog"
else
echo "$dir does not appear to contain a WP site"
fi
done
echo "Upgrade process done"