From 310d806dd3abe6ba5c53b4d6a07a2bbd81fa0a2b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 29 Jul 2019 17:08:30 +0930 Subject: [PATCH] plugins: document and extend the ~/.lightning/plugins/ dir. Load any plugins directly as well as subdirs. Signed-off-by: Rusty Russell --- CHANGELOG.md | 1 + doc/lightningd-config.5 | 6 +++--- doc/lightningd-config.5.txt | 4 +++- lightningd/plugin.c | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 800dc56bc..90f5682b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - build: now requires `python3-mako` to be installed, i.e. `sudo apt-get install python3-mako` +- plugins: if the config directory has a `plugins` subdirectory, those are loaded. - plugins: a new notification type `invoice_payment` (sent when an invoice is paid) has been added - plugins: a new 'channel_opened' notification type is added, which is emitted when a peer succesfully funds a channel to us - rpc: a new rpc command is added, `plugin`. It allows one to manage plugins without restarting `lightningd`. diff --git a/doc/lightningd-config.5 b/doc/lightningd-config.5 index 32c019121..79bf197d9 100644 --- a/doc/lightningd-config.5 +++ b/doc/lightningd-config.5 @@ -2,12 +2,12 @@ .\" Title: lightningd-config .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 06/30/2019 +.\" Date: 07/29/2019 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "LIGHTNINGD\-CONFIG" "5" "06/30/2019" "\ \&" "\ \&" +.TH "LIGHTNINGD\-CONFIG" "5" "07/29/2019" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -455,7 +455,7 @@ to authenticate to the Tor control port\&. .RE .SS "Lightning Plugins" .sp -lightningd(8) supports plugins, which offer additional configuration options and JSON\-RPC methods, depending on the plugin\&. Some are supplied by default (usually located in \fBlibexec/c\-lightning/plugins/\fR), but you can add your own, too\&. +lightningd(8) supports plugins, which offer additional configuration options and JSON\-RPC methods, depending on the plugin\&. Some are supplied by default (usually located in \fBlibexec/c\-lightning/plugins/\fR)\&. If a \fBplugins\fR directory exists under \fIlightning\-dir\fR that is searched for plugins along with any immediate subdirectories)\&. You can specify additional paths too: .PP \fBplugin\fR=\fIPATH\fR .RS 4 diff --git a/doc/lightningd-config.5.txt b/doc/lightningd-config.5.txt index bfb739437..74de4d510 100644 --- a/doc/lightningd-config.5.txt +++ b/doc/lightningd-config.5.txt @@ -328,7 +328,9 @@ Lightning Plugins lightningd(8) supports plugins, which offer additional configuration options and JSON-RPC methods, depending on the plugin. Some are supplied by default (usually located in -*libexec/c-lightning/plugins/*), but you can add your own, too. +*libexec/c-lightning/plugins/*). If a *plugins* directory exists +under 'lightning-dir' that is searched for plugins along with +any immediate subdirectories). You can specify additional paths too: *plugin*='PATH':: Specify a plugin to run as part of c-lightning. This can be specified diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 30a8425c4..c53da7432 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -909,6 +909,9 @@ void plugins_add_default_dir(struct plugins *plugins, const char *default_dir) DIR *d = opendir(default_dir); if (d) { struct dirent *di; + + /* Add this directory itself, and recurse down once. */ + add_plugin_dir(plugins, default_dir, true); while ((di = readdir(d)) != NULL) { if (streq(di->d_name, ".") || streq(di->d_name, "..")) continue;