Jump to content

ProcessWire upgrade script (shell)


Craig
 Share

Recommended Posts

Hello!

I've now got more than a handful of websites running ProcessWire - some running from master and some on development. As Development branch sometimes moves rather fast and I want to keep certain sites up to date with those changes, I wanted to make the upgrade process a bit quicker and smoother if I'm going to be doing it more often.

I made a quick and dirty bash script to handle this for me and thought I'd share it for others to make use of. I've only tested it on the hosting platform I use - Vidahost Cloud - which is Linux-based and has Git installed. So you'll probably need that sort of environment too :)

Get it here: wire-upgrade.sh.

The basic concept is as follows:

  1. Clone ProcessWire dev or master branch from Github to a temporary directory.
  2. Move the wire directory from the repository into the current directory named wire.new
  3. Rename wire to wire.backup....
  4. Rename wire.new to wire
  5. Remove the temporary directory from step 1.

The script should be ran in the site's root folder - the same level as the "wire" directory. Just specify which branch you want to upgrade to (master or dev) as the parameter (see comments at the top of the script for an example).

My shell scripting skills are a bit on the rusty side these days, but I think I've got most bases covered. Any feedback, improvements, comments or suggestions are very welcome :)

  • Like 2
Link to comment
Share on other sites

@Craig: that's a good idea and the script looks OK to me. Just some quick observations:

  • This doesn't seem to replace index.php, which does sometimes change (though very, very rarely, so perhaps not a problem at all)
  • Same thing with .htaccess, which could be even more problematic, since each site may have custom settings here (diff+notice?)

Also, if you're hosting multiple PW sites in the same location, generally speaking I'd suggest shared wire directories. Symlinks are good for that. This is what I've done to make upgrading a larg(e/ish) amount of sites at once feasible.

Anyway, great to see how others are solving this :)

  • Like 1
Link to comment
Share on other sites

Thanks for the feedback teppo! :)

Those are definitely very good points. I had forgot about index.php, mainly because I only ever having to upgrade that once or twice since I've started using ProcessWire. But I think that will be easy enough to add in.

.htaccess is a different issue altogether, with user customisations being quite likely (I know mine are always different). I like your idea of diffing the current one with the new one and providing a notice about it. Automating the replacement or merging of that would cause more problems than it's worth :)

The way my hosting is set up wouldn't allow for a single shared wire directory because the sites are all separate and on separate hosting accounts. But if I was running my own server then it's certainly something I'd consider.

Link to comment
Share on other sites

Diffing the .htaccess could be done only for the part between start- and endcomments for the processwire defaults. The only thing I use to change there is the rewritebase. Everything else comes at the end of the file after the last comment. So if the diffing would only detect the change of the rewritebase I know I've nothing to do.

Link to comment
Share on other sites

  • 10 months later...
 Share

×
×
  • Create New...