dropshell release 2025.0518.2308
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:
@@ -15,6 +15,7 @@
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
#include "utils/assert.hpp"
|
||||
#include "servers.hpp"
|
||||
|
||||
namespace dropshell
|
||||
{
|
||||
@@ -43,8 +44,8 @@ namespace dropshell
|
||||
Install components on a server. This is safe to re-run (non-destructive) and used to update
|
||||
servers and their services.
|
||||
|
||||
install (re)install dropshell components on this computer.
|
||||
install SERVER (re)install dropshell agent on the given server.
|
||||
install (re)install dropshell components on this computer, and on all servers.
|
||||
install SERVER (re)install dropshell agent on the particular given server.
|
||||
install SERVER [SERVICE|all] (re)install the given service (or all services) on the given server.
|
||||
|
||||
Note you need to create the service first with:
|
||||
@@ -159,6 +160,8 @@ namespace dropshell
|
||||
|
||||
int update_dropshell()
|
||||
{
|
||||
maketitle("Updating dropshell on this computer...");
|
||||
|
||||
// determine path to this executable
|
||||
std::filesystem::path dropshell_path = std::filesystem::canonical("/proc/self/exe");
|
||||
std::filesystem::path parent_path = dropshell_path.parent_path();
|
||||
@@ -202,8 +205,8 @@ namespace dropshell
|
||||
|
||||
if (currentver >= newver)
|
||||
{
|
||||
std::cout << "Current dropshell version: " << currentver << ", published version: " << newver << std::endl;
|
||||
std::cout << "No update needed." << std::endl;
|
||||
info << "Current dropshell version: " << currentver << ", published version: " << newver << std::endl;
|
||||
info << "Release version is not newer, no update needed." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -214,20 +217,22 @@ namespace dropshell
|
||||
rval = system(bash_script_2.c_str());
|
||||
if (rval != 0)
|
||||
{
|
||||
std::cerr << "Failed to install new version of dropshell." << std::endl;
|
||||
error << "Failed to install new version of dropshell." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::cout << "Successfully updated " << dropshell_path << " to the latest " << arch << " version." << std::endl;
|
||||
info << "Successfully updated " << dropshell_path << " to the latest " << arch << " version." << std::endl;
|
||||
|
||||
// execute the new version
|
||||
execlp("bash", "bash", "-c", (parent_path / "dropshell").c_str(), "install", (char *)nullptr);
|
||||
std::cerr << "Failed to execute new version of dropshell." << std::endl;
|
||||
error << "Failed to execute new version of dropshell." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int install_local_agent()
|
||||
{
|
||||
maketitle("Installing dropshell agent on this computer...");
|
||||
|
||||
std::vector<std::filesystem::path> paths = {
|
||||
gConfig().get_local_template_cache_path(),
|
||||
gConfig().get_local_backup_path(),
|
||||
@@ -239,7 +244,7 @@ namespace dropshell
|
||||
for (auto &p : paths)
|
||||
if (!std::filesystem::exists(p))
|
||||
{
|
||||
std::cout << "Creating directory: " << p << std::endl;
|
||||
info << "Creating directory: " << p << std::endl;
|
||||
std::filesystem::create_directories(p);
|
||||
}
|
||||
|
||||
@@ -249,39 +254,22 @@ namespace dropshell
|
||||
std::string cmd = "cd " + localpath::agent() + " && curl -fsSL -o bb64 https://gitea.jde.nz/public/bb64/releases/download/latest/bb64.amd64 && chmod a+x bb64";
|
||||
int ret = system(cmd.c_str());
|
||||
if (EXITSTATUSCHECK(ret))
|
||||
std::cout << "Downloaded local bb64 to " << localpath::agent() << std::endl;
|
||||
info << "Downloaded local bb64 to " << localpath::agent() << std::endl;
|
||||
else
|
||||
std::cerr << "Failed to download local bb64 to " << localpath::agent() << std::endl;
|
||||
error << "Failed to download local bb64 to " << localpath::agent() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Updating local bb64..." << std::endl;
|
||||
info << "Updating local bb64..." << std::endl;
|
||||
system((localpath::agent() + "bb64 -u").c_str()); // update.
|
||||
}
|
||||
|
||||
std::cout << "Creating local files to copy to remote agents..." << std::endl;
|
||||
info << "Creating local files to copy to remote agents..." << std::endl;
|
||||
recreate_agent::recreate_tree(localpath::files_for_remote_agent());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int install_host()
|
||||
{
|
||||
// update dropshell.
|
||||
// install the local dropshell agent.
|
||||
|
||||
int rval = update_dropshell();
|
||||
if (rval != 0)
|
||||
return rval;
|
||||
|
||||
rval = install_local_agent();
|
||||
if (rval != 0)
|
||||
return rval;
|
||||
|
||||
std::cout << "Installation complete." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int install_server(const std::string &server)
|
||||
{
|
||||
// install the dropshell agent on the given server.
|
||||
@@ -334,6 +322,35 @@ namespace dropshell
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// install_host
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
int install_host()
|
||||
{
|
||||
// update dropshell.
|
||||
// install the local dropshell agent.
|
||||
|
||||
int rval = update_dropshell();
|
||||
if (rval != 0)
|
||||
return rval;
|
||||
|
||||
rval = install_local_agent();
|
||||
if (rval != 0)
|
||||
return rval;
|
||||
|
||||
// install the dropshell agent on all servers.
|
||||
std::vector<ServerInfo> servers = get_configured_servers();
|
||||
for (const auto &server : servers)
|
||||
{
|
||||
rval = install_server(server.name);
|
||||
if (rval != 0)
|
||||
return rval;
|
||||
}
|
||||
|
||||
std::cout << "Installation complete." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// install command implementation
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user