User:Philip/plugin testing

From Habari Project

Jump to: navigation, search

Used to copy plugins for testing

This simply copies a plugin for testing, so is simple. It does not deal with specific tags or branches. It should be considered a temporary script that's usable for fixing the current plugin situation.

#!/usr/bin/env php
<?php
// Configure: Locations to copy the plugin
$plugin_dirs = array(
        '/var/www/6.myhabari.com/htdocs/user/plugins',
        '/var/www/7.myhabari.com/htdocs/user/plugins',
);
 
// Configure: Location of the plugins (likely a checkout from SVN)
$plugin_svn_dir = '/devel/svn/habari-extras/plugins';
 
/****************************************************************************/
if (empty($_SERVER['argv'][1])) {
        die("FAIL. Pass in plugin name and optionally branch (defaults to trunk)\n");
}
 
$plugin = trim($_SERVER['argv'][1]);
$branch = empty($_SERVER['argv'][2]) ? 'trunk' : trim($_SERVER['argv'][2]);
 
if (!is_dir($plugin)) {
        echo "FAIL: Plugin $plugin is not a directory.\n";
        exit;
}
 
if (!is_dir($plugin . '/' . $branch)) {
        echo "FAIL: Plugin $plugin/$branch is not a directory.\n";
        exit;
}
 
foreach ($plugin_dirs as $plugin_dir) {
 
	if (!is_dir($plugin_dir)) {
		echo "ERROR: Skipping $plugin_dir as it does not exist.\n";
		continue;
	}
 
	if (is_dir($plugin_dir . '/' . $plugin)) {
		echo "INFO: Skipping $plugin_dir/$plugin as it already exists\n";
		continue;
	}
 
	shell_exec("cp -R $plugin_svn_dir/$plugin/$branch $plugin_dir/$plugin");
 
	if (is_dir($plugin_dir . '/' . $plugin)) {
		echo "INFO: I created $plugin_dir/$plugin for you\n";
	} else {
		echo "ERROR: Tried but failed to created $plugin_dir/$plugin\n";
	}
}
Personal tools