Exemplo n.º 1
1
 public function __construct()
 {
     parent::__construct('list', 'plugin');
     $this->addOption('p|path:', 'path to plugins.json file', home_dir() . '/.moosh/plugins.json');
 }
Exemplo n.º 2
0
 public function execute()
 {
     global $CFG;
     require_once $CFG->libdir . '/adminlib.php';
     // various admin-only functions
     require_once $CFG->libdir . '/upgradelib.php';
     // general upgrade/install related functions
     require_once $CFG->libdir . '/environmentlib.php';
     require_once $CFG->dirroot . '/course/lib.php';
     $pluginname = $this->arguments[0];
     $moodleversion = $this->arguments[1];
     $pluginversion = $this->arguments[2];
     $pluginsfile = home_dir() . '/.moosh/plugins.json';
     $stat = @stat($pluginsfile);
     if (!$stat || time() - $stat['mtime'] > 60 * 60 * 24 || !$stat['size']) {
         die("plugins.json file not found or too old. Run moosh plugin-list to download newest plugins.json file\n");
     }
     $pluginsdata = file_get_contents($pluginsfile);
     $decodeddata = json_decode($pluginsdata);
     $downloadurl = NULL;
     $downloadurl = $this->get_plugin_url($decodeddata, $pluginname, $moodleversion, $pluginversion);
     if (!$downloadurl) {
         die("Couldn't find {$pluginname} {$moodleversion}\n");
     }
     $split = explode('_', $this->arguments[0], 2);
     $tempdir = home_dir() . '/.moosh/moodleplugins/';
     if (!file_exists($tempdir)) {
         mkdir($tempdir);
     }
     if (!fopen($tempdir . $split[1] . ".zip", 'w')) {
         echo "Failed to save plugin.\n";
         return;
     }
     try {
         file_put_contents($tempdir . $split[1] . ".zip", file_get_contents($downloadurl));
     } catch (Exception $e) {
         echo "Failed to download plugin. " . $e . "\n";
         return;
     }
     try {
         shell_exec("unzip " . $tempdir . $split[1] . ".zip -d " . home_dir() . "/.moosh/moodleplugins/");
         shell_exec("cp -r " . $tempdir . $split[1] . "/ " . $this->get_install_path($split[0], $moodleversion));
     } catch (Exception $e) {
         echo "Failed to unzip plugin. " . $e . "\n";
         return;
     }
     echo "Installing {$pluginname} {$moodleversion}\n";
     upgrade_noncore(true);
     echo "Done\n";
 }
Exemplo n.º 3
0
    }
    exit(1);
}
$parser->setSpecs($subcommand_specs[$subcommand]);
try {
    $subcommand_options[$subcommand] = $parser->continueParse();
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
    die("Moosh global options should be passed before command not after it.");
}
while (!$parser->isEnd()) {
    $arguments[] = $parser->advance();
}
// Read config file if available.
$moodlerc = NULL;
$home_dir = home_dir();
if (file_exists($home_dir . DIRECTORY_SEPARATOR . ".mooshrc.php")) {
    $moodlerc = $home_dir . DIRECTORY_SEPARATOR . ".mooshrc.php";
} elseif (file_exists("/etc/moosh/mooshrc.php")) {
    $moodlerc = "/etc/moosh/mooshrc.php";
} elseif (file_exists($home_dir . DIRECTORY_SEPARATOR . "mooshrc.php")) {
    $moodlerc = $home_dir . DIRECTORY_SEPARATOR . "mooshrc.php";
}
$options = NULL;
if ($moodlerc) {
    if (isset($app_options['verbose'])) {
        echo "Using '{$moodlerc}' as moosh runtime configuration file\n";
    }
    $options = array();
    require $moodlerc;
    $options = array_merge_recursive_distinct($defaultOptions, $options);
Exemplo n.º 4
0
 private function get_plugins_data()
 {
     $pluginsfile = home_dir() . '/.moosh/plugins.json';
     $stat = @stat($pluginsfile);
     if (!$stat || time() - $stat['mtime'] > 60 * 60 * 24 || !$stat['size']) {
         die("plugins.json file not found or too old. Run moosh plugin-list to download newest plugins.json file\n");
     }
     $pluginsdata = file_get_contents($pluginsfile);
     $decodeddata = json_decode($pluginsdata);
     return $decodeddata;
 }
Exemplo n.º 5
0
}
while (!$parser->isEnd()) {
    $arguments[] = $parser->advance();
}
//read config file if available
$moodlerc = NULL;
if (file_exists(home_dir() . DIRECTORY_SEPARATOR . ".mooshrc.php")) {
    $moodlerc = home_dir() . DIRECTORY_SEPARATOR . ".mooshrc.php";
} elseif (file_exists("/etc/moosh/mooshrc.php")) {
    $moodlerc = "/etc/moosh/mooshrc.php";
} elseif (file_exists(home_dir() . DIRECTORY_SEPARATOR . "mooshrc.php")) {
    $moodlerc = home_dir() . DIRECTORY_SEPARATOR . "mooshrc.php";
}
// Create directory for configuration if one is not there already.
if (!file_exists(home_dir() . "/.moosh")) {
    @mkdir(home_dir() . "/.moosh");
}
$options = NULL;
if ($moodlerc) {
    if (isset($app_options['verbose'])) {
        echo "Using '{$moodlerc}' as moosh runtime configuration file\n";
    }
    $options = array();
    require $moodlerc;
    $options = array_merge_recursive_distinct($defaultOptions, $options);
} else {
    $options = $defaultOptions;
}
/**
 * @var Moosh\MooshCommand $subcommand
 *
Exemplo n.º 6
0
 public function __construct()
 {
     parent::__construct('list', 'plugin');
     $this->addOption('p|path:', 'path to plugins.json file', home_dir() . '/.moosh/plugins.json');
     $this->addOption('v|versions', 'display plugin versions instead of supported moodle versions');
 }