aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-01-12 18:00:20 -0800
committerredmatrix <git@macgirvin.com>2016-01-12 18:00:20 -0800
commitf757285ea8f0a7f82f84c00061ff1ab6c69a9aa0 (patch)
tree58684a0baebc854a3193e93678ac1ceb707645fe /util
parentbaedd253090e1129dfea8284ee6dc29649286b3b (diff)
downloadvolse-hubzilla-f757285ea8f0a7f82f84c00061ff1ab6c69a9aa0.tar.gz
volse-hubzilla-f757285ea8f0a7f82f84c00061ff1ab6c69a9aa0.tar.bz2
volse-hubzilla-f757285ea8f0a7f82f84c00061ff1ab6c69a9aa0.zip
cli utility for managing addons
Diffstat (limited to 'util')
-rwxr-xr-xutil/addons130
1 files changed, 130 insertions, 0 deletions
diff --git a/util/addons b/util/addons
new file mode 100755
index 000000000..602cc228e
--- /dev/null
+++ b/util/addons
@@ -0,0 +1,130 @@
+#!/usr/bin/env php
+<?php
+
+// Hubzilla plugin management utility
+
+function usage() {
+echo <<< EOT
+ Usage:
+ util/addons list # list installed addons
+ util/addons list all # list all addons (*)= installed, (!)= disabled due to version compatibility
+ util/addons install foo # install addon named 'foo'
+ util/addons uninstall foo # uninstall addon named 'foo'
+EOT;
+}
+
+require_once('include/cli_startup.php');
+
+cli_startup();
+$a = get_app();
+
+ $plugs = get_config('system', 'addon');
+ $plugins_arr = array();
+
+ if($plugs)
+ $plugins_arr = explode(',', str_replace(' ', '', $plugs));
+
+ $a->plugins = $plugins_arr;
+
+ $plugins = array();
+ $files = glob('addon/*/');
+ if($files) {
+ foreach($files as $file) {
+ if(is_dir($file)){
+ list($tmp, $id) = array_map('trim', explode('/', $file));
+ $info = get_plugin_info($id);
+ $enabled = in_array($id,$a->plugins);
+ $x = check_plugin_versions($info);
+ if($enabled && ! $x) {
+ $enabled = false;
+ $idz = array_search($id, $a->plugins);
+ if ($idz !== false) {
+ unset($a->plugins[$idz]);
+ uninstall_plugin($id);
+ set_config("system","addon", implode(", ",$a->plugins));
+ }
+ }
+ $info['disabled'] = 1-intval($x);
+
+ $plugins[] = array( $id, (($enabled)? '*' : '') , $info);
+ }
+ }
+ }
+
+if($argc == 1) {
+ usage();
+ killme();
+}
+
+
+if($argc == 2 && $argv[1] === 'list') {
+ $r = q("select * from addon where installed = 1");
+ if($r) {
+ foreach($r as $rr) {
+ echo $rr['name'] . "\n";
+ }
+ }
+ killme();
+}
+
+if($argc == 3 && $argv[1] === 'list' && $argv[2] === 'all') {
+
+ if($plugins) {
+ foreach($plugins as $p) {
+ echo $p[0] . (($p[1]) ? $p[1] : (($p[2]['disabled']) ? '!' : '')) . "\n";
+ }
+ }
+
+ killme();
+}
+
+
+if($argc == 3 && $argv[1] === 'install') {
+
+ if($plugins) {
+ foreach($plugins as $p) {
+ if($p[0] === $argv[2]) {
+ if($p[1])
+ echo $p[0] . ' already installed.' . "\n";
+ elseif($p[2]['disabled'])
+ echo $p[0] . ' disabled (version compatibility).' . "\n";
+ else {
+ $a->plugins[] = $p[0];
+ install_plugin($p[0]);
+ set_config("system","addon", implode(", ",$a->plugins));
+ echo $p[0] . ' installed.' . "\n";
+ }
+ }
+ }
+ }
+
+ killme();
+}
+
+
+
+if($argc == 3 && $argv[1] === 'uninstall') {
+
+ if($plugins) {
+ foreach($plugins as $p) {
+ if($p[0] === $argv[2]) {
+ if(! $p[1])
+ echo $p[0] . ' not installed.' . "\n";
+ elseif($p[2]['disabled'])
+ echo $p[0] . ' disabled (version compatibility).' . "\n";
+ else {
+ $idx = array_search($p[0], $a->plugins);
+ if ($idx !== false)
+ unset($a->plugins[$idx]);
+ uninstall_plugin($p[0]);
+ set_config("system","addon", implode(", ",$a->plugins));
+ echo $p[0] . ' uninstalled.' . "\n";
+ }
+ }
+ }
+ }
+
+ killme();
+}
+
+