dropshell release 2025.0521.2125
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
This commit is contained in:
@ -27,9 +27,9 @@ struct CreateServerCommandRegister {
|
||||
create_server_handler,
|
||||
create_server_autocomplete,
|
||||
false, // hidden
|
||||
false, // requires_config
|
||||
false, // requires_install
|
||||
0, // min_args (after command)
|
||||
true, // requires_config
|
||||
true, // requires_install
|
||||
1, // min_args (after command)
|
||||
1, // max_args (after command)
|
||||
"create-server [SERVER]",
|
||||
"Create a new server entry on this host.",
|
||||
|
63
source/src/commands/create-template.cpp
Normal file
63
source/src/commands/create-template.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "command_registry.hpp"
|
||||
#include "config.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
#include "utils/directories.hpp"
|
||||
#include "shared_commands.hpp"
|
||||
#include "version.hpp"
|
||||
#include "utils/assert.hpp"
|
||||
#include "templates.hpp"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
|
||||
namespace dropshell {
|
||||
|
||||
void create_template_autocomplete(const CommandContext& ctx);
|
||||
int create_template_handler(const CommandContext& ctx);
|
||||
|
||||
static std::vector<std::string> create_template_name_list={"create-template"};
|
||||
|
||||
// Static registration
|
||||
struct CreateTemplateCommandRegister {
|
||||
CreateTemplateCommandRegister() {
|
||||
CommandRegistry::instance().register_command({
|
||||
create_template_name_list,
|
||||
create_template_handler,
|
||||
create_template_autocomplete,
|
||||
false, // hidden
|
||||
true, // requires_config
|
||||
true, // requires_install
|
||||
1, // min_args (after command)
|
||||
1, // max_args (after command)
|
||||
"create-template TEMPLATE",
|
||||
"Create a new template.",
|
||||
// heredoc
|
||||
R"(
|
||||
Create a new template.
|
||||
|
||||
create-template TEMPLATE
|
||||
)"
|
||||
});
|
||||
}
|
||||
} create_template_command_register;
|
||||
|
||||
|
||||
void create_template_autocomplete(const CommandContext& ctx) {
|
||||
return; // can't autocomplete as it's a new server!
|
||||
}
|
||||
|
||||
|
||||
int create_template_handler(const CommandContext& ctx) {
|
||||
// create a new server entry on this host
|
||||
if (ctx.args.size() == 0) {
|
||||
error << "No template name provided" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
bool ok = gTemplateManager().create_template(ctx.args[0]);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace dropshell
|
@ -45,7 +45,7 @@ struct HelpCommandRegister {
|
||||
|
||||
|
||||
void help_autocomplete(const CommandContext& ctx) {
|
||||
if (ctx.args.size() == 1) {
|
||||
if (ctx.args.size() == 0) {
|
||||
// list all commands
|
||||
for (const auto& cmd : CommandRegistry::instance().list_primary_commands(false)) {
|
||||
rawout << cmd << std::endl;
|
||||
|
@ -238,17 +238,22 @@ namespace dropshell
|
||||
{
|
||||
maketitle("Installing dropshell agent on this computer...");
|
||||
|
||||
// clear out old cruft.
|
||||
std::filesystem::remove_all(localpath::agent_local());
|
||||
std::filesystem::remove_all(localpath::agent_remote());
|
||||
|
||||
// recreate the directories.
|
||||
localpath::create_directories();
|
||||
|
||||
// create the agent-local directory.
|
||||
recreate_agent_local::recreate_tree(localpath::agent());
|
||||
// populate the agent-local directory.
|
||||
recreate_agent_local::recreate_tree(localpath::agent_local());
|
||||
|
||||
// run the local agent installer.
|
||||
execute_local_command(localpath::agent(), "agent-install.sh",{}, nullptr, cMode::Defaults | cMode::NoBB64);
|
||||
execute_local_command(localpath::agent_local(), "agent-install.sh",{}, nullptr, cMode::Defaults | cMode::NoBB64);
|
||||
|
||||
// create the agent-remote directory.
|
||||
// populate the agent-remote directory.
|
||||
info << "Creating local files to copy to remote agents..." << std::endl;
|
||||
recreate_agent_remote::recreate_tree(localpath::files_for_remote_agent());
|
||||
recreate_agent_remote::recreate_tree(localpath::agent_remote());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -275,7 +280,7 @@ namespace dropshell
|
||||
// now create the agent.
|
||||
// copy across from the local agent files.
|
||||
info << "Copying local agent files to remote server... " << std::flush;
|
||||
shared_commands::rsync_tree_to_remote(localpath::files_for_remote_agent(), agent_path, server_env, false);
|
||||
shared_commands::rsync_tree_to_remote(localpath::agent_remote(), agent_path, server_env, false);
|
||||
info << "done." << std::endl;
|
||||
|
||||
// run the agent installer. Can't use BB64 yet, as we're installing it on the remote server.
|
||||
|
Reference in New Issue
Block a user