Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have my CMS upgrade itself?

I've built a CMS (using the Codeigniter PHP framework) that we use for all our clients. I'm constantly tweaking it, and it gets hard to keep track of which clients have which version. We really want everyone to always have the latest version.

I've written it in a way so that updates and upgrades generally only involve uploading the new version via FTP, and deleting the old one - I just don't touch the /uploads or /themes directories (everything specific to the site is either there or in the database). Everything is a module, and each module has it's own version number (as well as the core CMS), as well as an install and uninstall script for each version, but I have to manually FTP the files first, then run the module's install script from the control panel. I wrote and will continue to write everything personally, so I have complete control over the code.

What I'd like is to be able to upgrade the core CMS and individual modules from the control panel of the CMS itself. This is a "CMS for Dummies", so asking people to FTP or do anything remotely technical is out of the question. I'm envisioning something like a message popping up on login, or in the list of installed modules, like "New version available".

I'm confident that I can sort out most of the technical details once I get this going, but I'm not sure which direction to take. I can think of ways to attempt this with cURL (to authenticate and pull source files from somewhere on our server) and PHP's native filesystem functions like unlink(), file_put_contents(), etc. to preform the actual updates to files or stuff the "old" CMS in a backup directory and set up the new one, but even as I'm writing this post - it sounds like a recipe for disaster.

I don't use git/github or anything, but I have the feeling something like that could help? How should (or shouldn't) I approach this?

like image 255
Wesley Murch Avatar asked Sep 25 '11 11:09

Wesley Murch


3 Answers

Theres a bunch of ways to do this but the least complicated is just to have Git installedo n your client servers and set up a cron job that runs a git pull origin master every now and then. If your application uses Migrations it should be easy as hell to do.

You can do this as it sounds like you are in full control of your clients. For something like PyroCMS or PancakeApp that doesn't work because anyone can have it on any server and we have to be a little smarter. We just download a ZIP which contains all changed files and a list of deleted files, which means the file system is updated nicely.

We have a list of installations which we can ping with a HTTP request so the system knows to run the download, or the click can hit "Upgrade" when they log in.

like image 174
Phil Sturgeon Avatar answered Nov 07 '22 01:11

Phil Sturgeon


You can use Git from your CMS: Glip. The cron would be a url on your own system, without installing Git.

like image 41
Alfonso Rubalcava Avatar answered Nov 07 '22 02:11

Alfonso Rubalcava


@Obsidian Wouldn't a DNS poisoning attack also compromise most methods being mentioned in this thread?

Additionally SSH could be compromised by a man in the middle attack as well.

While total paranoia is a good thing when dealing with security, Wordpress being a GPL codebase would make it easy to detect an unauthorized code change in your code if such an attack did occur, so resolution would be easy.

SSH and Git does sound like a good solution, but what is the intended audience?

like image 1
The Cranky Coder Avatar answered Nov 07 '22 01:11

The Cranky Coder