mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
plugins: make the default plugins directory a member of 'plugins'
This commit is contained in:
parent
73bbf4f6a3
commit
5bdf349771
@ -943,18 +943,19 @@ void clear_plugins(struct plugins *plugins)
|
||||
tal_free(p);
|
||||
}
|
||||
|
||||
void plugins_add_default_dir(struct plugins *plugins, const char *default_dir)
|
||||
void plugins_add_default_dir(struct plugins *plugins)
|
||||
{
|
||||
DIR *d = opendir(default_dir);
|
||||
DIR *d = opendir(plugins->default_dir);
|
||||
if (d) {
|
||||
struct dirent *di;
|
||||
|
||||
/* Add this directory itself, and recurse down once. */
|
||||
add_plugin_dir(plugins, default_dir, true);
|
||||
add_plugin_dir(plugins, plugins->default_dir, true);
|
||||
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);
|
||||
add_plugin_dir(plugins, path_join(tmpctx, plugins->default_dir,
|
||||
di->d_name), true);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
@ -968,8 +969,8 @@ void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
|
||||
struct jsonrpc_request *req;
|
||||
|
||||
plugins->pending_manifests = 0;
|
||||
plugins_add_default_dir(plugins,
|
||||
path_join(tmpctx, plugins->ld->config_dir, "plugins"));
|
||||
plugins->default_dir = path_join(plugins, plugins->ld->config_dir, "plugins");
|
||||
plugins_add_default_dir(plugins);
|
||||
|
||||
setenv("LIGHTNINGD_PLUGIN", "1", 1);
|
||||
setenv("LIGHTNINGD_VERSION", version(), 1);
|
||||
|
@ -84,6 +84,7 @@ struct plugins {
|
||||
struct log_book *log_book;
|
||||
|
||||
struct lightningd *ld;
|
||||
const char *default_dir;
|
||||
};
|
||||
|
||||
/* The value of a plugin option, which can have different types.
|
||||
@ -115,10 +116,9 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
||||
struct lightningd *ld);
|
||||
|
||||
/**
|
||||
* Search for `default_dir`, and if it exists add every directory it
|
||||
* contains as a plugin dir.
|
||||
* Recursively add all plugins from the default plugins directory.
|
||||
*/
|
||||
void plugins_add_default_dir(struct plugins *plugins, const char *default_dir);
|
||||
void plugins_add_default_dir(struct plugins *plugins);
|
||||
|
||||
/**
|
||||
* Initialize the registered plugins.
|
||||
|
@ -223,8 +223,7 @@ plugin_dynamic_rescan_plugins(struct command *cmd)
|
||||
struct plugin *p;
|
||||
|
||||
/* This will not fail on "already registered" error. */
|
||||
plugins_add_default_dir(cmd->ld->plugins,
|
||||
path_join(tmpctx, cmd->ld->config_dir, "plugins"));
|
||||
plugins_add_default_dir(cmd->ld->plugins);
|
||||
|
||||
found = false;
|
||||
list_for_each(&cmd->ld->plugins->plugins, p, list) {
|
||||
|
Loading…
Reference in New Issue
Block a user