Created
August 8, 2013 09:35
-
-
Save mbrammer/6183194 to your computer and use it in GitHub Desktop.
Shell script to check WordPress versions of virtual hosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Colors | |
ESC_SEQ="\033[" | |
COL_RESET=$ESC_SEQ"39m" | |
COL_RED=$ESC_SEQ"31m" | |
COL_GREEN=$ESC_SEQ"32m" | |
COL_YELLOW=$ESC_SEQ"33m" | |
COL_BLUE=$ESC_SEQ"34m" | |
COL_MAGENTA=$ESC_SEQ"35m" | |
COL_CYAN=$ESC_SEQ"36m" | |
# Where to start scanning | |
WEBHOME=/var/www/vhosts | |
# Directoy depth | |
WEBHOMECOUNT=$(($(echo "${WEBHOME}"|grep -o "/"|wc -l| sed s/\ //g)+2)) | |
echo "==============================================================================" | |
echo "Wordpress versions in $WEBHOME" | |
echo "------------------------------------------------------------------------------" | |
# Other projects could use 'version.php' too so we include 'wp-includes/' in our search to limit it to WordPress | |
for i in $(tree -L 8 -if ${WEBHOME} | grep 'wp-includes/version.php'); do | |
SITE=$(echo $i|awk -v count="$WEBHOMECOUNT" -F/ '{for(j=count;j<=NF-2;j++) \ | |
printf $j"/"}' | sed 's/.$//g') | |
VERSION=$(grep "wp_version = " $i|awk -F\' '{print $2}') | |
echo " $COL_YELLOW$SITE $COL_RESET- $COL_RED$VERSION$COL_RESET" | |
done | |
echo "------------------------------------------------------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment