#ifndef SHARED_COMMANDS_HPP #define SHARED_COMMANDS_HPP #include "servers.hpp" #include "command_registry.hpp" #include "server_env_manager.hpp" namespace dropshell { namespace shared_commands { typedef enum HealthStatus { HEALTHY, UNHEALTHY, NOTINSTALLED, ERROR, UNKNOWN } HealthStatus; typedef struct ServiceStatus { HealthStatus health; std::vector ports; } ServiceStatus; // expose routines used by multiple commands. class cRemoteTempFolder { public: cRemoteTempFolder(const server_env_manager &server_env); // create a temp folder on the remote server ~cRemoteTempFolder(); // delete the temp folder on the remote server std::string path() const; // get the path to the temp folder on the remote server private: std::string mPath; const server_env_manager &mServerEnv; }; bool rsync_tree_to_remote( const std::string &local_path, const std::string &remote_path, server_env_manager &server_env, bool silent); std::string get_arch(); std::map get_all_services_status(std::string server_name); std::string healthtick(const std::string &server, const std::string &service); std::string HealthStatus2String(HealthStatus status); HealthStatus is_healthy(const std::string &server, const std::string &service); std::string healthmark(const std::string &server, const std::string &service); void std_autocomplete(const CommandContext &ctx); void std_autocomplete_allowall(const CommandContext &ctx); class cBackupFileName { public: cBackupFileName(const std::string &server, const std::string &service, const std::string &template_name); cBackupFileName(const std::string &filename); std::string get_filename() const; std::string get_server() const; std::string get_service() const; std::string get_template_name() const; std::string get_datetime() const; bool is_valid() const; private: std::string mServer; std::string mService; std::string mTemplateName; std::string mDatetime; }; bool scp_file_to_remote(const server_env_manager &server_env, const std::string &local_path, const std::string &remote_path, bool silent); bool scp_file_from_remote(const server_env_manager &server_env, const std::string &remote_path, const std::string &local_path, bool silent); // defined in backupdata.cpp, used by restoredata.cpp. bool backupdata_service(const std::string& server, const std::string& service); // defined in uninstall.cpp bool uninstall_service(const std::string &server, const std::string &service); // defined in nuke.cpp bool nuke_service(const std::string &server, const std::string &service); // defined in install.cpp bool install_service(const std::string &server, const std::string &service); // defined in create-service.cpp bool create_service(const std::string &server_name, const std::string &template_name, const std::string &service_name); } // namespace shared_commands } // namespace dropshell #endif