Last active
August 29, 2015 14:01
-
-
Save phillcoxon/29d03acdfba852253277 to your computer and use it in GitHub Desktop.
Find old WordPress installs
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 | |
| # Finds WP installs and displays version numbers in current directory, or directory specified by -d <path> | |
| # Very rough - needs tidy up and improvement | |
| # Would be cool if it could look up latest version and compare any installs found to show only old installs | |
| function usage | |
| { | |
| echo "usage: locate_old_wp_versions.sh [-d | --dir] [-h | --help]" | |
| } | |
| # Set default dir | |
| if [ "$DIR" == "" ]; then | |
| DIR=./ | |
| fi | |
| # Get parameters | |
| while [ "$1" != "" ]; do | |
| case $1 in | |
| -d | --dir ) shift | |
| DIR=$1 | |
| ;; | |
| -h | --help ) usage | |
| exit | |
| ;; | |
| * ) usage | |
| exit 1 | |
| esac | |
| shift | |
| done | |
| echo "Finding WP installs in ${DIR}" | |
| # Needs tidy up on displaying the output | |
| for FILE in $(find ${DIR} -path "*wp-includes/version.php"); do | |
| BASENAME="${FILE%.[^.]*}" | |
| DIRNAME="${BASENAME%/[^/]*}" | |
| FILENAME="${BASENAME:${#DIRNAME} + 1}" | |
| EXT="${FILE##*\.}" | |
| # FIX: pull only the version number | |
| VERSION=`grep "wp_version\ =" ${FILE}` | |
| #FIX: Compare with current WP version and only display out of date installs | |
| #FIX: Improve output display | |
| echo "${DIRNAME} - ${VERSION}" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment