Move templates.
Remove docker stuff.
This commit is contained in:
@@ -31,7 +31,7 @@ namespace dropshell
|
||||
false, // hidden
|
||||
false, // requires_config
|
||||
false, // requires_install
|
||||
1, // min_args (after command)
|
||||
0, // min_args (after command)
|
||||
2, // max_args (after command)
|
||||
"install SERVER [SERVICE]",
|
||||
"Install/reinstall service(s). Safe/non-destructive way to update.",
|
||||
@@ -138,7 +138,9 @@ namespace dropshell
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// get_arch : SHARED COMMAND
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
std::string get_arch()
|
||||
{
|
||||
// determine the architecture of the system
|
||||
@@ -151,6 +153,26 @@ namespace dropshell
|
||||
return arch;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// update_dropshell
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
std::string _exec(const char* cmd) {
|
||||
char buffer[128];
|
||||
std::string result = "";
|
||||
FILE* pipe = popen(cmd, "r");
|
||||
if (!pipe) {
|
||||
throw std::runtime_error("popen() failed!");
|
||||
}
|
||||
while (!feof(pipe)) {
|
||||
if (fgets(buffer, 128, pipe) != nullptr)
|
||||
result += buffer;
|
||||
}
|
||||
pclose(pipe);
|
||||
return result;
|
||||
}
|
||||
|
||||
int update_dropshell()
|
||||
{
|
||||
// determine path to this executable
|
||||
@@ -189,6 +211,21 @@ namespace dropshell
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string runvercmd = (parent_path / "dropshell").string() + " version";
|
||||
std::string currentver = _exec(runvercmd.c_str());
|
||||
runvercmd = (parent_path / "dropshell_temp").string() + " version";
|
||||
std::string newver = _exec(runvercmd.c_str());
|
||||
|
||||
if (currentver >= newver)
|
||||
{
|
||||
std::cout << "Current dropshell version: " << currentver << ", published version: " << newver << std::endl;
|
||||
std::cout << "No update needed." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
std::string bash_script_2 = "docker run --rm -v " + parent_path.string() + ":/target gitea.jde.nz/public/debian-curl:latest " +
|
||||
"sh -c \"mv /target/dropshell_temp /target/dropshell\"";
|
||||
rval = system(bash_script_2.c_str());
|
||||
@@ -212,6 +249,8 @@ namespace dropshell
|
||||
{
|
||||
// update dropshell.
|
||||
// install the local dropshell agent.
|
||||
|
||||
return update_dropshell();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -16,6 +16,7 @@ namespace dropshell {
|
||||
// defined in install.cpp
|
||||
bool install_service(const std::string& server, const std::string& service, bool silent);
|
||||
bool uninstall_service(const std::string& server, const std::string& service, bool silent);
|
||||
std::string get_arch();
|
||||
|
||||
// defined in health.cpp
|
||||
std::string healthtick(const std::string& server, const std::string& service);
|
||||
@@ -24,6 +25,7 @@ namespace dropshell {
|
||||
// defined in standard_autocomplete.cpp
|
||||
void std_autocomplete(const CommandContext& ctx);
|
||||
void std_autocomplete_allowallservices(const CommandContext& ctx);
|
||||
|
||||
|
||||
|
||||
} // namespace dropshell
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user