dropshell release 2025.0524.1149
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 17s
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 17s
This commit is contained in:
@@ -28,23 +28,22 @@ namespace dropshell
|
||||
if (server_name.empty())
|
||||
return;
|
||||
|
||||
// Construct the full path to server.json
|
||||
std::string server_env_path = localfile::server_json(server_name);
|
||||
std::string server_json_path = localfile::server_json(server_name);
|
||||
|
||||
// Check if file exists
|
||||
if (!std::filesystem::exists(server_env_path))
|
||||
if (!std::filesystem::exists(server_json_path))
|
||||
{
|
||||
std::cerr << "Server environment file not found: " + server_env_path << " for server " << server_name << std::endl;
|
||||
std::cerr << "Server environment file not found: " + server_json_path << " for server " << server_name << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Use envmanager to handle the environment file
|
||||
nlohmann::json server_env_json = nlohmann::json::parse(std::ifstream(server_env_path));
|
||||
nlohmann::json server_env_json = nlohmann::json::parse(std::ifstream(server_json_path));
|
||||
if (server_env_json.empty())
|
||||
{
|
||||
error << "Failed to parse server environment file at "<< server_env_path << std::endl;
|
||||
error << "Failed to parse server environment file at "<< server_json_path << std::endl;
|
||||
info << "The returned json was empty." << std::endl;
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +95,7 @@ namespace dropshell
|
||||
|
||||
if (mUsers.empty())
|
||||
{
|
||||
error << "No users defined in server configuration " << server_env_path << std::endl;
|
||||
error << "No users defined in server configuration " << server_json_path << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ namespace dropshell
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
error << "Failed to parse " << server_env_path << std::endl;
|
||||
error << "Failed to parse " << server_json_path << std::endl;
|
||||
error << "Error: " << e.what() << std::endl;
|
||||
|
||||
mValid = false;
|
||||
@@ -334,30 +333,10 @@ namespace dropshell
|
||||
argstr += " " + quote(dequote(trim(arg)));
|
||||
}
|
||||
|
||||
if (env_vars.find("RUNAS") == env_vars.end())
|
||||
{
|
||||
error << "Error: RUNAS is not set in .template_info.env for the service." << std::endl;
|
||||
return std::nullopt;
|
||||
}
|
||||
std::string runas = env_vars.find("RUNAS")->second;
|
||||
if (runas != "root" && runas != "user")
|
||||
{
|
||||
error << "Error: RUNAS is not set to root or user in .template_info.env for the service." << std::endl;
|
||||
return std::nullopt;
|
||||
}
|
||||
bool run_as_root = runas == "root";
|
||||
|
||||
if (run_as_root && !hasRootUser())
|
||||
{
|
||||
error << "Error: The service " << service_name << " is set to run as root on the remote server, but the server environment does not allow root services." << std::endl;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
sCommand sc(
|
||||
remote_service_template_path,
|
||||
quote(script_path) + argstr + (silent ? " > /dev/null 2>&1" : ""),
|
||||
env_vars,
|
||||
run_as_root);
|
||||
env_vars);
|
||||
|
||||
if (sc.empty())
|
||||
{
|
||||
@@ -427,7 +406,7 @@ namespace dropshell
|
||||
|
||||
// 3. create a template server.env file in the server directory
|
||||
std::string user = getenv("USER");
|
||||
std::string server_env_path = server_dir + "/server.json";
|
||||
std::string server_env_path = server_dir + "/" + filenames::server_json;
|
||||
std::ofstream server_env_file(server_env_path);
|
||||
server_env_file << "{" << std::endl;
|
||||
server_env_file << " \"SSH_HOST\": \"" << server_name << "\"," << std::endl;
|
||||
|
Reference in New Issue
Block a user