-
Notifications
You must be signed in to change notification settings - Fork 4
/
wp-mass-plugins.sh
51 lines (40 loc) · 1.35 KB
/
wp-mass-plugins.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
#!/bin/sh
# Obtain a list of all plugins on all WP sites on the server.
# Before a major upgrade, redirect output to a file and compare
# to a list of known-incompatible plugins.
# This script is always safe to run and does not change anything.
# Iterate over array of installations and split vars into components:
# path|URL|email|owner
# Path on server where wp-mass-tools are kept:
scriptpath='/root/scripts/wp-mass-tools'
# Read in the array of WP sites from external file
source ./wp-sites.sh
echo "Extracting list of plugins"
echo
# Iterate through array, upgrading each
for blog in ${site[@]}
do
#echo $blog
dir=$(echo $blog | cut -f1 -d\|)
url=$(echo $blog | cut -f2 -d\|)
email=$(echo $blog | cut -f3 -d\|)
owner=$(echo $blog | cut -f4 -d\|)
# Get the db name from wp-config.
cd $dir
dbname=`grep -i "db_name" wp-config.php | sed s/define\(\'DB_NAME\',\ //g | sed s/\).*$//g | sed s/\'//g`
echo
echo "Examining WordPress installation:"
echo "Dir: $dir"
echo "URL: $url"
echo "E-mail: $email"
echo "User: $owner"
echo "Database: $dbname"
# List of active plugins is serialized in a single db field and difficult to extract from shell.
# Use an external PHP script to grab them instead.
echo
echo "Active plugins:"
php -f $scriptpath/wp-find-plugins.php $dbname
echo
echo "-------------------"
echo
done