dropshell release 2025.0518.2236
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled

This commit is contained in:
Your Name
2025-05-18 22:37:00 +12:00
parent d80820db15
commit cf8738aee9
8 changed files with 45 additions and 25 deletions

View File

@ -11,7 +11,6 @@ namespace dropshell
{
int create_service_handler(const CommandContext &ctx);
bool create_service(const std::string &server_name, const std::string &template_name, const std::string &service_name);
void create_service_autocomplete(const CommandContext &ctx);
static std::vector<std::string> create_service_name_list = {"create-service"};
@ -45,7 +44,7 @@ namespace dropshell
std::string service = safearg(ctx.args, 1);
std::string template_name = safearg(ctx.args, 2);
return create_service(server, template_name, service) ? 0 : 1;
return shared_commands::create_service(server, template_name, service) ? 0 : 1;
}
void create_service_autocomplete(const CommandContext &ctx)
@ -63,6 +62,9 @@ namespace dropshell
}
}
namespace shared_commands
{
bool create_service(const std::string &server_name, const std::string &template_name, const std::string &service_name)
{
if (server_name.empty() || template_name.empty() || service_name.empty())
@ -117,4 +119,6 @@ namespace dropshell
return true;
}
} // namespace shared_commands
} // namespace dropshell

View File

@ -61,7 +61,7 @@ namespace dropshell
service_info = get_service_info(server, service);
if (!SIvalid(service_info))
error << "Warning: Invalid service: " << service << std::endl;
error << "Invalid service: " << service << std::endl;
if (server_env.check_remote_dir_exists(remotepath::service(server, service)))
{

View File

@ -174,8 +174,20 @@ namespace dropshell
return 1;
}
{ // create the new service
info << "3) Creating new service..." << std::endl;
if (!shared_commands::create_service(server, service_info.template_name, service))
return 1;
}
{ // installing fresh service
info << "4) Install of fresh service..." << std::endl;
if (!shared_commands::install_service(server, service))
return 1;
}
{ // restore service from backup
info << "3) Restoring service data from backup..." << std::endl;
info << "5) Restoring service data from backup..." << std::endl;
std::string remote_backups_dir = remotepath::backups(server);
std::string remote_backup_file_path = remote_backups_dir + "/" + backup_details->get_filename();
@ -190,11 +202,7 @@ namespace dropshell
server_env.run_remote_template_command(service, "restore", {}, false, {{"BACKUP_FILE", remote_backup_file_path}, {"TEMP_DIR", remote_temp_folder.path()}});
} // dtor of remote_temp_folder will clean up the temp folder on the server
{ // installing fresh service
info << "4) Non-destructive install of fresh service..." << std::endl;
if (!shared_commands::install_service(server, service))
return 1;
}
{ // healthcheck the service
info << "5) Healthchecking service..." << std::endl;

View File

@ -93,6 +93,9 @@ namespace dropshell
// defined in install.cpp
bool install_service(const std::string &server, const std::string &service);
// defined in create-service.cpp
bool create_service(const std::string &server_name, const std::string &template_name, const std::string &service_name);
} // namespace shared_commands
} // namespace dropshell
#endif