Created
November 22, 2013 02:09
-
-
Save israelshirk/7593634 to your computer and use it in GitHub Desktop.
Batch updates wordpress plugins from SVN
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
| export BASEPATH=/var/web/vhosts/ | |
| export SVNPATH=/var/web/wordpress-plugins/ | |
| # Don't modify after this point. | |
| export CONTENT_DIRS=`find ${BASEPATH} -name wp-content` | |
| export PLUGIN_DIRS=`find ${CONTENT_DIRS} -maxdepth 1 -mindepth 1 -type d -name plugins` | |
| export PLUGIN_FOLDERS=`find ${PLUGIN_DIRS} -maxdepth 1 -mindepth 1 -type d` | |
| export PLUGIN_NAMES=`echo ${PLUGIN_FOLDERS} | xargs -n 1 basename | sort | uniq -u` | |
| export OLD_PLUGIN_DATE=`date +%s` | |
| export DATESTAMP=`date +%s` | |
| for i in $PLUGIN_NAMES; do | |
| cd ${SVNPATH}; | |
| if [ ! -d $i ]; then | |
| svn checkout http://plugins.svn.wordpress.org/$i $i; | |
| if [ ! -d $i ]; then | |
| continue | |
| fi | |
| cd $i; | |
| else | |
| cd $i; | |
| svn update; | |
| fi | |
| rm -f latest; | |
| cd tags; | |
| export VERSION=`python -c 'import glob; import re; v = glob.glob("[0-9]*"); v = [re.sub(r"([0-9\.]*)[^0-9\.]*", r"\1", num) for num in v]; v = [num for num in v if num]; v.sort(key=lambda s : map(int, s.split("."))); print v[-1]'`; | |
| echo $i $VERSION | |
| cd ..; | |
| if [ -d tags/${VERSION} ]; then | |
| ln -s tags/${VERSION} latest; | |
| else | |
| ln -s trunk latest | |
| fi | |
| done; | |
| for folder in ${PLUGIN_FOLDERS}; do | |
| PLUGIN_NAME=`basename $folder` | |
| if [ ! -d ${SVNPATH}${PLUGIN_NAME} ]; then | |
| echo "Skipping ${folder}" | |
| continue | |
| fi; | |
| export OLD_PLUGIN_FOLDER=`echo $folder | sed "s#wp-content/plugins#wp-content/plugins-${DATESTAMP}#"` | |
| mkdir -p ${OLD_PLUGIN_FOLDER} | |
| rsync --exclude .svn -rp $folder $OLD_PLUGIN_FOLDER | |
| rsync --exclude .svn -rp ${SVNPATH}${PLUGIN_NAME}/latest/ $folder | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment