SVN WordPress Updater

Ever have a whole mess of svn WordPress installs you needed to update. Hate doing them one at a time? Use this program to update a whole bunch, or a single install. All you have to remember is the program name, two flags, and the version you want to use.

Current Version is now on github. https://github.com/mossiso/SVN-Multiple-WordPress-Updater

wpupdate 1.6.1 (08.03.10)

#------------------------------------------------------------------------------#
#                           Change log
#
# v0.7      09.04.07 - Fixed some minor text by adding ellipses at the end of
#                       text. Added a constant for where to save the svn
#                       reports.
#
# v0.8      01.03.08 - Figured out the HELPTEXT variable stuff and updated the
#                       text.
#                    - Moved the code that asks for the file location and
#                       creates the array to be within the if...else... logic
#                       so --help works, and if no version is given, the help
#                       text is displayed.
#
# v0.9      02.26.08 - Added ability to have comments in the FILENAME file.
#                       Commented lines begin with a semi-colon ";". Edited the
#                       HELPTEXT.
#
# v1.0      03.31.08 - Changed the way permissions are done. Only files/folders
#                       starting  with "wp-" should be altered. Added a "/" in
#                       the "Don't forget to run..." line.  Changed the prompt
#                       asking for the file containing svn installs. Allows for
#                       a default location hard coded into the program with the
#                       FILENAME variable.
# v1.1      04.29.08 - Changed the
#                       line for option 'd' in the first prompt to use the
#                       FILENAME variable.
#
# v1.2      07.18.08 - Script will now run the DB upgrade.php script using
#                       curl. Pulls the info from the database for that
#                       install.
#
# v1.3      07.30.08 - Added a line that prints out any svn errors. And made a
#                       check to see if the url variable has a value. Don't run
#                       curl unless it does.
#
# v1.4      12.01.08 - Changed default behavior to use the svn branches instead
#                       of tags
#
# v1.5      12.11.08 - Converted script to use command line flags (options)
#
# v1.5.1    01.27.09 - Fixed the ability to use -i, just a directory, and
#                       changed default behavior to update current directory if
#                       no -f or -i flag given.
# v1.5.2    03.19.09 - Added check for the size of wp-content. If larger than
#                       100MB, it won't backup the directory.
#                    - Changed the sed call to get the table prefix to check for
#                       single ( ' ) and double ( " ) quotes. There were two
#                       variables checking for this, so changed code to use the
#                       first one only.
#                    - Removed the comment out section about old way to ask for
#                       files.
#                    - Fixed conditional statement checking for value in url
#                       variable. Also made a check to only run the update
#                       script if the url variable starts with 'http', otherwise
#                       it just reminds you to run it.
# v1.5.3    06.25.09 - fixed the way to get the tb_prefix variable. If the
#                       wp-config.php file was created before version 2.1 of WP
#                       then the script did not get the table prefix corrrectly.
#                    - updated a few script prompts
# v1.5.4    07.14.09 - store svn reports in a wpupdate-reports folder. Checks if
#                       exists. If not then creates it as a subdirectory of
#                       REPORTSPATH.
# v1.5.5    01.07.10 - add an option to skip the fixing of permissions and owner
#                       and an option to not use sudo
# v1.5.5    03.09.10 - changed the SVN repository to the new URL
#                    - Added the set commands to end the script correctly if an
#                       unset variable is found or a statement returns non-true.
# v1.6      07.23.10 - Added check for SVN repository. If the current repository
#                       is not the same as the default, prompt user for which
#                       repo to use.
#                    - Changed script to use the owner of the wp-content folder
#                       instead of the .svn folder. All permissions changes use
#                       the owner of the wp-content folder instead of the .svn
#                       folder
#                    - Added a few checks for using sudo and running command in
#                       in non-sudo if that option is used.
#                    - Added some comments into the script
#                    - Added some color to the output.
#                    - Added an option that just outputs the default repo used
#                    - Added a check for the 'home' field in the WP database,
#                       and to use the 'siteurl' field instead if the 'home' is
#                       empty. This is the URL to use for updating the database
#                       after upgrading.
# v1.6.1             - Added option to skip the backups
#------------------------------------------------------------------------------#

Usage: wpupdate [OPTIONS]... [VERSION NUMBER]
Switch or update the WordPress install(s) to the VERSION NUMBER.

Example: wpupdate -f /home/wp-versions -u -b 2.7
This would update all of the installs listed in wp-versions to the 2.7 branch.

"wpupdate -h" for help

OPTIONS:
 -f     path to a file containing a list of paths to WordPress installs, can
        not be used with -i (single install) option. File must consist of full
        paths in the form "/wwwroot/sites/mossiso.com/blog/" each on a separate
        line. A ";" semi-colon designates a commented line.

 -i     path to  a single svn install, can not be used with -f (versions file)
        option

 -r     output the default SVN repo used and exit
 -s     svn URL to use for updates (defaults to 'http://svn.core.wordpress.org')

 -u     use "svn update", can not be used with -w (switch) option
 -w     use "svn switch", can not be used with -u (update) option

 -b     use the branches, can not be used with -t (tags) option
 -t     use the tags, can not be used with -b (branches) option

 -o     path to output file containing report of svn update. File will be
        created if it does not exist. The directories must already exist. The
        default is to save it to your home directory (ex. '/home/user')

 -h     display this help info
 -v     outputs version information and exits

 -k     skip backing up the wp-content folder and database
 -n     run as a normal user, do not use sudo
 -x     skip fixing permissions and owners

WHAT IT DOES:
    First the wpupudate program makes a backup copy of the MySQL database and
    the wp-contents/ directory. It places these backups in the WP install
    directory.

    A WordPress version must be specified. By default the WordPress installs
    are upgraded to the specified branch install. If the -t (tags) option is
    used, the installs will be updated to the specified tag version. If the -w
    (switch) option is used, then the installs are switched to the branch (by
    default) or tag (with -t option) version specified.

THINGS TO KNOW:
    By default the program runs as sudo. To run as normal user, pass the -n
    flag.  This user must have absolute privileges over all files in the
    WordPress folders.

    If the -f or -i flags are not given on the command line, the program will
    attempt to update the current directory.

    You will be prompted for a MySQL user and pass that must have access to all
    of the databases (ex. MySQL root or admin account). Unless the -n flag is
    passed you will be prompted for your user password to enable sudo.

Older versions:
wpupdate 1.6 (07.30.10)
wpupdate 1.5.2 (03.19.09)

———————————————————————————————–

WP Versions

This little script will output a file with all of the WP installs (svn and non) on your server. It uses the ‘locate’ command, so the results will typically show what was on the server the day before.

USAGE:
When using this script with the WP Update script above, you will need to edit the generated file and remove the leading semi-colon ‘;’ from the lines containing the install paths you wish to update.

#------------------------------------------------------------------------------#
#   Locate all installs of WordPress on the server.                            #
#                                                                              #
#   Supply the path to save the file. File does not need to exist.             #
#                                                                              #
#   @Author: Ammon Shepherd                                                    #
#   @Date:   08.03.10                                                          #
    VERSION="1.3.1"                                                            #
#                                                                              #
#   CHANGE LOG:                                                                #
#       03.17.09    - Added check so that program can't overwrite itself...    #
#                     cause I just did that...  Changed some echoed text.      #
#       07.23.10    - Added check for repository. Changed layout of report.    #
#       08.03.10    - Added totals to the bottom of the file.                  #
#                   - Added BASH check for unset variables and return values   #
#------------------------------------------------------------------------------#

wpversions 1.3.1 (08.03.10)

Older versions:
wpversions 1.3 (07.30.10)
wpversions 1.2 (03.17.09)

0 thoughts on “SVN WordPress Updater

  1. Pingback: Richard Cutts (rpcutts) 's status on Wednesday, 12-Aug-09 12:29:15 UTC - Identi.ca

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>