.
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled

This commit is contained in:
Your Name
2025-05-12 23:53:52 +12:00
parent d946c18d7c
commit 5201e92cb3
9 changed files with 73 additions and 48 deletions

View File

@@ -50,7 +50,7 @@ struct EditCommandRegister {
// ------------------------------------------------------------------------------------------------
// utility function to edit a file
// ------------------------------------------------------------------------------------------------
bool edit_file(const std::string &file_path)
bool edit_file(const std::string &file_path, bool has_bb64)
{
// make sure parent directory exists.
std::string parent_dir = get_parent(file_path);
@@ -72,7 +72,15 @@ bool edit_file(const std::string &file_path)
}
std::cout << "Editing file: " << file_path << std::endl;
return execute_local_command(editor_cmd, nullptr, cMode::Interactive);
if (has_bb64) {
return execute_local_command(editor_cmd, nullptr, cMode::Interactive);
}
else {
// might not have bb64 at this early stage. Direct edit.
int ret = system(editor_cmd.c_str());
return EXITSTATUSCHECK(ret);
}
}
// ------------------------------------------------------------------------------------------------
@@ -84,7 +92,7 @@ int edit_config()
gConfig().save_config(false); // save defaults.
std::string config_file = localfile::dropshell_json();
if (!edit_file(config_file) || !std::filesystem::exists(config_file))
if (!edit_file(config_file, false) || !std::filesystem::exists(config_file))
return die("Error: Failed to edit config file.");
gConfig().load_config();
@@ -92,6 +100,9 @@ int edit_config()
return die("Error: Failed to load and parse edited config file!");
gConfig().save_config(true);
// make sure we have executables.
std::cout << "Successfully edited config file at " << config_file << std::endl;
return 0;
}
@@ -113,7 +124,7 @@ int edit_server(const std::string &server_name)
<< "Once moved, reinstall all services with: dropshell install " << server_name;
std::string config_file = serverpath + "/server.env";
if (!edit_file(config_file)) {
if (!edit_file(config_file, true)) {
std::cerr << "Error: Failed to edit server.env" << std::endl;
std::cerr << "You can manually edit this file at: " << config_file << std::endl;
std::cerr << "After editing, " << aftertext.str() << std::endl;
@@ -135,7 +146,7 @@ int edit_service_config(const std::string &server, const std::string &service)
return 1;
}
if (edit_file(config_file) && std::filesystem::exists(config_file))
if (edit_file(config_file, true) && std::filesystem::exists(config_file))
std::cout << "To apply your changes, run:\n dropshell install " + server + " " + service << std::endl;
return 0;
}

View File

@@ -88,7 +88,7 @@ bool install_service(const std::string& server, const std::string& service, bool
// Create service directory
std::string remote_service_path = remotepath::service(server, service);
std::string mkdir_cmd = "mkdir -p " + quote(remote_service_path);
if (!execute_ssh_command(server_env.get_SSH_INFO(), sCommand("",remotepath::executables(server), mkdir_cmd, {}), cMode::Silent))
if (!execute_ssh_command(server_env.get_SSH_INFO(), sCommand("", mkdir_cmd, {}), cMode::Silent))
{
std::cerr << "Failed to create service directory " << remote_service_path << std::endl;
return false;
@@ -96,7 +96,7 @@ bool install_service(const std::string& server, const std::string& service, bool
// Check if rsync is installed on remote host
std::string check_rsync_cmd = "which rsync";
if (!execute_ssh_command(server_env.get_SSH_INFO(), sCommand("",remotepath::executables(server), check_rsync_cmd, {}), cMode::Silent))
if (!execute_ssh_command(server_env.get_SSH_INFO(), sCommand("", check_rsync_cmd, {}), cMode::Silent))
{
std::cerr << "rsync is not installed on the remote host" << std::endl;
return false;