mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
Add a default 'plugins' directory in the lightning dir
Automatically load all plugins from 'lightning_dir/plugins' (setting them as plugin_dir)
This commit is contained in:
@@ -900,6 +900,20 @@ void clear_plugins(struct plugins *plugins)
|
|||||||
tal_free(p);
|
tal_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void plugins_add_default_dir(struct plugins *plugins, const char *default_dir)
|
||||||
|
{
|
||||||
|
DIR *d = opendir(default_dir);
|
||||||
|
if (d) {
|
||||||
|
struct dirent *di;
|
||||||
|
while ((di = readdir(d)) != NULL) {
|
||||||
|
if (streq(di->d_name, ".") || streq(di->d_name, ".."))
|
||||||
|
continue;
|
||||||
|
add_plugin_dir(plugins, path_join(tmpctx, default_dir, di->d_name), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(d);
|
||||||
|
}
|
||||||
|
|
||||||
void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
|
void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
|
||||||
{
|
{
|
||||||
struct plugin *p;
|
struct plugin *p;
|
||||||
@@ -910,6 +924,8 @@ void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
|
|||||||
plugins->pending_manifests = 0;
|
plugins->pending_manifests = 0;
|
||||||
uintmap_init(&plugins->pending_requests);
|
uintmap_init(&plugins->pending_requests);
|
||||||
|
|
||||||
|
plugins_add_default_dir(plugins, path_join(tmpctx, plugins->ld->config_dir, "plugins"));
|
||||||
|
|
||||||
setenv("LIGHTNINGD_PLUGIN", "1", 1);
|
setenv("LIGHTNINGD_PLUGIN", "1", 1);
|
||||||
/* Spawn the plugin processes before entering the io_loop */
|
/* Spawn the plugin processes before entering the io_loop */
|
||||||
list_for_each(&plugins->plugins, p, list) {
|
list_for_each(&plugins->plugins, p, list) {
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ struct plugin_opt;
|
|||||||
struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
||||||
struct lightningd *ld);
|
struct lightningd *ld);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for `default_dir`, and if it exists add every directory it
|
||||||
|
* contains as a plugin dir.
|
||||||
|
*/
|
||||||
|
void plugins_add_default_dir(struct plugins *plugins, const char *default_dir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the registered plugins.
|
* Initialize the registered plugins.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user