Install is broken - putting the wrong template on.
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:
parent
ddc57173cb
commit
a5243a7e79
@ -57,16 +57,33 @@ namespace dropshell
|
||||
// step 1 - destroy on remote server.
|
||||
if (server_env.is_valid())
|
||||
{
|
||||
LocalServiceInfo service_info;
|
||||
std::string user = server_env.get_user_for_service(service); // returns empty string if no user found.
|
||||
if (user.empty())
|
||||
{
|
||||
warning << "No user found for service " << service << " on " << server << std::endl;
|
||||
for (auto sshuser : server_env.get_users())
|
||||
{
|
||||
if (server_env.check_remote_dir_exists(remotepath(server, sshuser.user).service(service), sshuser.user))
|
||||
{
|
||||
info << "Found a remote service directory here: " << remotepath(server, sshuser.user).service(service) << std::endl;
|
||||
info << "Deleting it as user " << sshuser.user << std::endl;
|
||||
user = sshuser.user;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user.empty())
|
||||
warning << "No remote service directory found for " << service << " on " << server << std::endl;
|
||||
else
|
||||
{ // user is not empty.
|
||||
LocalServiceInfo service_info;
|
||||
service_info = get_service_info(server, service);
|
||||
bool service_valid = SIvalid(service_info);
|
||||
if (!service_valid)
|
||||
warning << "Invalid service: " << service << std::endl;
|
||||
warning << "No valid service definition found for " << service << std::endl;
|
||||
|
||||
std::string user = server_env.get_user_for_service(service);
|
||||
bool remote_dir_exists = server_env.check_remote_dir_exists(remotepath(server, user).service(service), user);
|
||||
if (remote_dir_exists)
|
||||
if (server_env.check_remote_dir_exists(remotepath(server, user).service(service), user))
|
||||
{
|
||||
// run the destroy script on the remote server if it exists.
|
||||
// otherwise just uninstall.
|
||||
@ -97,25 +114,28 @@ namespace dropshell
|
||||
warning << "Failed to remove remote service directory" << std::endl;
|
||||
}
|
||||
else
|
||||
warning << "Service not found on remote server: " << remotepath(server, user).service(service) << std::endl;
|
||||
}
|
||||
warning << "No remote service directory found for " << service << " on "<< server << std::endl;
|
||||
} // user is not empty.
|
||||
} // server_env is valid.
|
||||
else
|
||||
warning << "Can't destroy the remote service as the server is invalid: " << server << std::endl;
|
||||
error << "No valid local server information for server " << server << std::endl;
|
||||
|
||||
// step 2 - destroy the local service directory.
|
||||
// step 2 - destroy the local service directory, if it exists.
|
||||
std::string local_service_path = localpath::service(server, service);
|
||||
if (local_service_path.empty() || !std::filesystem::exists(local_service_path))
|
||||
{
|
||||
warning << "Local service directory not found: " << local_service_path << std::endl;
|
||||
warning << "No local service directory found for " << service << " on " << server << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto itemsdeleted = std::filesystem::remove_all(local_service_path);
|
||||
if (itemsdeleted == 0)
|
||||
error << "Failed to remove local service directory" << std::endl;
|
||||
else
|
||||
info << "Local service directory removed: " << local_service_path << std::endl;
|
||||
}
|
||||
|
||||
info << "Destroyed service " << service << " on server " << server << std::endl;
|
||||
info << "Finished destroying service " << service << " on server " << server << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -196,18 +196,36 @@ namespace dropshell
|
||||
|
||||
bool ServerConfig::check_remote_dir_exists(const std::string &dir_path, std::string user) const
|
||||
{
|
||||
if (user.empty())
|
||||
{
|
||||
debug << "Can't check remote directory exists for " << dir_path << " as user is empty" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
sCommand scommand("", "test -d " + quote(dir_path), {});
|
||||
return execute_ssh_command(get_SSH_INFO(user), scommand, cMode::Silent);
|
||||
}
|
||||
|
||||
bool ServerConfig::check_remote_file_exists(const std::string &file_path, std::string user) const
|
||||
{
|
||||
if (user.empty())
|
||||
{
|
||||
debug << "Can't check remote file exists for " << file_path << " as user is empty" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
sCommand scommand("", "test -f " + quote(file_path), {});
|
||||
return execute_ssh_command(get_SSH_INFO(user), scommand, cMode::Silent);
|
||||
}
|
||||
|
||||
bool ServerConfig::check_remote_items_exist(const std::vector<std::string> &file_paths, std::string user) const
|
||||
{
|
||||
if (user.empty())
|
||||
{
|
||||
debug << "Can't check remote items exist as user is empty" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// convert file_paths to a single string, separated by spaces
|
||||
std::string file_paths_str;
|
||||
std::string file_names_str;
|
||||
|
@ -89,7 +89,7 @@ namespace dropshell
|
||||
// check the service directory exists.
|
||||
if (!fs::exists(service.local_service_path))
|
||||
{
|
||||
std::cerr << "Error: Service directory not found: " << service.local_service_path << std::endl;
|
||||
warning << "Service directory not found: " << service.local_service_path << std::endl;
|
||||
return LocalServiceInfo();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user