tags:

views:

50

answers:

2

I have close to 30 wordpress installs that will grow very rapidly to double that number.

Each of these sites has the same theme that I frequently am updating.

I'd like to create a script on one of my servers that acts as a control panel for all my sites so that I can push out an updated theme file for all selected sites. The sites will be on multiple servers.

My interface consists of a list of sites (http://site1.com, http://site2.com, etc) with a checkbox beside each one and an "Update Sites" button at the bottom of the list.

I'd like to enable my "Update Sites" button to go out to all those selected sites and update/overwrite the files inside my theme directory with the updated version of the theme (which will always be stored in a specific known directory on this specific server).

Any help you could provide on the functions required would be appreciated.

In terms of authentication, Ideally, I would like to avoid having to supply login credentials for each individual site. Rather, I'd like to place something inside the site that would serve as a handshake token between my update server script and the target site. Not sure if this is possible or allowed with wordpress.

+1  A: 

You're looking for rsync + ssh with passwordless key authentication, not something in PHP. Wheel reinvention imminent.

(You could still execute the rsync command from your PHP script, obviously.)

foreach ($hosts as $host) { exec("rsync theme_dir_here $host:theme_dir_here"); }
janmoesen
@janmoesen > I'm off to check out rsync + ssh. Sounds like it could be the ticket. I'm definitely not into reinventing the wheel :-)
Scott B
+1 we do this where I work to sync out libraries etc to multiple servers, works really well.
Jake Worrell
@@janmoesen > Quick question: What does the receiving site have to have in order to participate? Can the key be stored in the wp plugins folder?
Scott B
Scott: keys are generally stored in the ~/.ssh directory, but you can specify them on the command line or in the ~/.ssh/config file to be anywhere you want. I add host aliases in ~/.ssh/config and store the corresponding keys in the ~/.ssh directory. See man ssh_config.
janmoesen
A: 

I think you could create a program on each installation that can grab files from a server predefined server when called. It then copies the theme files it got into the themes folder, and change the wordpress settings file to use the new theme.

The page that you discribed would just call the file on each installation you choose with cURL.

Jonah Bron
@Jonah Bron > So the central server would link to a specific file on the target server (the processor file) and that processor file would then grab the update files from the central server. Correct? And the processor file would do nothing until executed by the central server. Do you see any reason that authentication would be required? It sounds like the script to script communication could have a predefined passphrase to handle basic security, then I'd just limit what the processor script could do and where it could write to, yes?
Scott B
@Scott B > I don't think it needs permission because it reads from the central server. It would need some sort of authentication if the theme files were being uploaded from the caller through POST, but they're not. Even if an unauthorized person called it, it would just grab the theme from your server, affecting nothing. It is pretty much impossible for someone to upload unauthorized data.
Jonah Bron
@Jonah Bron, that sounds like the most straight forward approach, though the rsync + ssh sounds very interesting too. For your suggested approach, I will just place some code (file_get_contents('http://mycentralserveraddress.com/updater.zip') in the processor script (at the target site) that loads the update zip file from the central server, and extracts it to the appropriate directories, right?
Scott B
That's right. Though, it would still need to change the settings in Wordpress to use the new theme (obviously).
Jonah Bron
Cool. I'm getting a fatal error trying to run this as a plug in from my local machine. I've got the updater.zip on a remote server. Care to take a peak at this follow-up question and give me a shout? http://stackoverflow.com/questions/2314285/server-to-server-retrieve-and-extract-a-remote-zip-file-to-local-server-directo
Scott B