// server_service.hpp // // manage a service on a server // #include #include #include #include "server_env.hpp" namespace dropshell { std::vector get_server_services(const std::string& server_name); class server_service { public: server_service(); bool init(const std::string& server_name, const std::string& service_name); // install the service over ssh, using the credentials from _server.env (via server_env.hpp), by: // 1. check if the server_name exists, and the service_name refers to a valid template // 2. check if service_name is valid for the server_name // 3. create the service directory on the server at {DROPSHELL_DIR}/{service_name} // 3. copy the template files into that service directory/template (from the templates directory for the specified server, using templates.hpp to identify the path) // 4. copying the {service_name}.env file to the service directory (from the server directory for the specified server) // 5. running the install.sh script on the server, passing the {service_name}.env file as an argument bool install(); // 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 // then run the command, passing the {service_name}.env file as an argument // do a lot of checks, such as: // checking that we can ssh to the server. // checking whether the service directory exists on the server. // checking that the command exists in the service directory. // checking that the command is a valid .sh file. // checking that the {service_name}.env file exists in the service directory. bool run_command(const std::string& command); // backup the service over ssh, using the credentials from _server.env (via server_env.hpp) // 1. run backup.sh on the server // 2. create a backup file with format server-service-datetime.tgz // 3. store it in the server's DROPSHELL_DIR/backups folder // 4. copy it to the local user_dir/backups folder bool backup(); private: std::string m_server_name; std::string m_service_name; std::unique_ptr m_server_env; }; } // namespace dropshell