aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorHaakon Meland Eriksen <haakon.eriksen@far.no>2016-01-14 18:14:30 +0100
committerHaakon Meland Eriksen <haakon.eriksen@far.no>2016-01-14 18:14:30 +0100
commit72353bf0446901f1711cba7a2e50dbce9bd06227 (patch)
tree6b73f79bf7386e69e4941ff5a8b4c165830b1652 /util
parent42433c0b4442f1a6b451324fe7f765b1b4c354b8 (diff)
parent9f9fdc1434b7283171f8d843f225228cdb322115 (diff)
downloadvolse-hubzilla-72353bf0446901f1711cba7a2e50dbce9bd06227.tar.gz
volse-hubzilla-72353bf0446901f1711cba7a2e50dbce9bd06227.tar.bz2
volse-hubzilla-72353bf0446901f1711cba7a2e50dbce9bd06227.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'util')
-rwxr-xr-xutil/addons132
-rwxr-xr-xutil/hz36
2 files changed, 168 insertions, 0 deletions
diff --git a/util/addons b/util/addons
new file mode 100755
index 000000000..2c128c50e
--- /dev/null
+++ b/util/addons
@@ -0,0 +1,132 @@
+#!/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') {
+ if($plugins) {
+ foreach($plugins as $p) {
+ if($p[1]) {
+ echo $p[0] . "\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();
+}
+
+
diff --git a/util/hz b/util/hz
new file mode 100755
index 000000000..baa5bfb55
--- /dev/null
+++ b/util/hz
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Simple, minimalist command line tool to post status to hubzilla via the API. Requires curl.
+# Put it in your path, and sneeze your statuses to the zot network from your shell.
+
+CONF=${HOME}/.hubzilla
+
+usage () {
+echo "usage: hz [conffile]"
+echo "Create a conf file, either in .hubzilla in your home directory, or supplied as an arg"
+echo " USER=youruserame "
+echo " PASS=yourpass"
+echo " HUB=your.hub.domain.org"
+echo
+echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Hit ENTER to send."
+
+}
+
+CUR=`which curl`
+
+[ "$CUR" ] || { echo "curl is not installed or on your path"; usage; exit 1; }
+
+[ "$1" ] && CONF="$1"
+
+
+. ${CONF}
+
+[ "$USER" ] || { echo "no USER"; usage; exit 1; }
+[ "$PASS" ] || { echo "no PASS"; usage; exit 1; }
+[ "$HUB" ] || { echo "no HUB"; usage; exit 1; }
+
+echo "enter your message to be posted as $USER @ $HUB, then hit ENTER to send:"
+
+(read MSG; curl -ssl -u${USER}:${PASS} --data-urlencode "status=${MSG}" https://${HUB}/api/statuses/update )
+
+