hmm
This commit is contained in:
parent
3c03c2a536
commit
d95500f679
@ -170,10 +170,12 @@ void create_server(const std::string &server_name)
|
||||
server_env_file.close();
|
||||
|
||||
// 4. add dropshell-agent service to server
|
||||
std::string service_dir = server_dir + "/dropshell-agent";
|
||||
std::filesystem::create_directory(service_dir);
|
||||
std::string service_env_path = service_dir + "/service.env";
|
||||
std::filesystem::copy(get_local_system_templates_path() + "/dropshell-agent/example/service.env", service_env_path);
|
||||
create_service(server_name, "dropshell-agent", "dropshell-agent", true); // silently create service.
|
||||
|
||||
// std::string service_dir = server_dir + "/dropshell-agent";
|
||||
// std::filesystem::create_directory(service_dir);
|
||||
// std::string service_env_path = service_dir + "/service.env";
|
||||
// std::filesystem::copy(get_local_system_templates_path() + "/dropshell-agent/example/service.env", service_env_path);
|
||||
|
||||
std::cout << "Server created successfully: " << server_name << std::endl;
|
||||
std::cout << "Please complete the installation:" <<std::endl;
|
||||
|
@ -134,7 +134,7 @@ std::set<std::string> list_backups(const std::string &service_name)
|
||||
return backups;
|
||||
}
|
||||
|
||||
bool create_service(const std::string &server_name, const std::string &template_name, const std::string &service_name)
|
||||
bool create_service(const std::string &server_name, const std::string &template_name, const std::string &service_name, bool silent)
|
||||
{
|
||||
if (server_name.empty() || template_name.empty() || service_name.empty())
|
||||
return false;
|
||||
@ -143,27 +143,36 @@ bool create_service(const std::string &server_name, const std::string &template_
|
||||
|
||||
if (service_dir.empty())
|
||||
{
|
||||
std::cerr << "Error: Couldn't locate server " << server_name << " in any config directory" << std::endl;
|
||||
std::cerr << "Please check the server name is correct and try again" << std::endl;
|
||||
std::cerr << "You can list all servers with 'dropshell servers'" << std::endl;
|
||||
std::cerr << "You can create a new server with 'dropshell create-server " << server_name << "'" << std::endl;
|
||||
if (!silent)
|
||||
{
|
||||
std::cerr << "Error: Couldn't locate server " << server_name << " in any config directory" << std::endl;
|
||||
std::cerr << "Please check the server name is correct and try again" << std::endl;
|
||||
std::cerr << "You can list all servers with 'dropshell servers'" << std::endl;
|
||||
std::cerr << "You can create a new server with 'dropshell create-server " << server_name << "'" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fs::exists(service_dir))
|
||||
{
|
||||
std::cerr << "Error: Service already exists: " << service_name << std::endl;
|
||||
std::cerr << "Current service path: " << service_dir << std::endl;
|
||||
if (!silent)
|
||||
{
|
||||
std::cerr << "Error: Service already exists: " << service_name << std::endl;
|
||||
std::cerr << "Current service path: " << service_dir << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template_info tinfo;
|
||||
if (!get_template_info(template_name, tinfo))
|
||||
{
|
||||
std::cerr << "Error: Template '" << template_name << "' not found" << std::endl;
|
||||
std::cerr << "Please check the template name is correct and try again" << std::endl;
|
||||
std::cerr << "You can list all templates with 'dropshell templates'" << std::endl;
|
||||
std::cerr << "You can create a new template with 'dropshell create-template " << template_name << "'" << std::endl;
|
||||
if (!silent)
|
||||
{
|
||||
std::cerr << "Error: Template '" << template_name << "' not found" << std::endl;
|
||||
std::cerr << "Please check the template name is correct and try again" << std::endl;
|
||||
std::cerr << "You can list all templates with 'dropshell templates'" << std::endl;
|
||||
std::cerr << "You can create a new template with 'dropshell create-template " << template_name << "'" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -173,11 +182,14 @@ bool create_service(const std::string &server_name, const std::string &template_
|
||||
// copy the template example files to the service directory
|
||||
recursive_copy(tinfo.local_template_path+"/example", service_dir);
|
||||
|
||||
std::cout << "Service " << service_name <<" created successfully"<<std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "To complete the installation, please:" << std::endl;
|
||||
std::cout << "1. edit the service.env file: dropshell edit " << server_name << " " << service_name << std::endl;
|
||||
std::cout << "2. install the remote service: dropshell install " << server_name << " " << service_name << std::endl;
|
||||
if (!silent)
|
||||
{
|
||||
std::cout << "Service " << service_name <<" created successfully"<<std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "To complete the installation, please:" << std::endl;
|
||||
std::cout << "1. edit the service.env file: dropshell edit " << server_name << " " << service_name << std::endl;
|
||||
std::cout << "2. install the remote service: dropshell install " << server_name << " " << service_name << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace dropshell {
|
||||
// list all backups for a given service (across all servers)
|
||||
std::set<std::string> list_backups(const std::string& service_name);
|
||||
|
||||
bool create_service(const std::string& server_name, const std::string& template_name, const std::string& service_name);
|
||||
bool create_service(const std::string& server_name, const std::string& template_name, const std::string& service_name, bool silent=false);
|
||||
} // namespace dropshell
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user