diff --git a/src/main.cpp b/src/main.cpp index 69a0e05..0b14024 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -211,7 +211,7 @@ int main(int argc, char* argv[]) { for (const auto& service_info : servicelist) { dropshell::service_runner runner(server_name, service_info.service_name); - if (!runner.isValid) { + if (!runner.isValid()) { std::cerr << "Error: Failed to initialize service" << std::endl; return 1; } diff --git a/src/service_runner.hpp b/src/service_runner.hpp index 22dd988..915899a 100644 --- a/src/service_runner.hpp +++ b/src/service_runner.hpp @@ -32,7 +32,7 @@ typedef struct ServiceStatus { class service_runner { public: service_runner(const std::string& server_name, const std::string& service_name); - bool isValid; + bool isValid() const { return mValid; } // run a command over ssh, using the credentials from server.env (via server_env.hpp) // first check that the command corresponds to a valid .sh file in the service directory diff --git a/src/services.cpp b/src/services.cpp index 2f26b7f..2785b8c 100644 --- a/src/services.cpp +++ b/src/services.cpp @@ -67,7 +67,17 @@ ServiceInfo get_service_info(const std::string &server_name, const std::string & std::string local_service_env_path = get_local_service_env_path(server_name, service_name); envmanager env(local_service_env_path); if (!env.load()) { - std::cerr << "Error: service.env missing from " << local_service_env_path << std::endl; + if (std::filesystem::exists(get_local_service_path(server_name, service_name))) + std::cerr << "Error: service malformed - service.env missing from " << local_service_env_path << std::endl; + else + { + template_info tinfo; + get_template_info(service_name, tinfo); + std::string template_name = service_name; + if (tinfo.local_template_path.empty()) + template_name = "TEMPLATE"; + std::cerr << "Error: you need to create that service first, with: dropshell create-service " << server_name << " "<