#ifndef SHARED_COMMANDS_HPP #define SHARED_COMMANDS_HPP #include "servers.hpp" #include "command_registry.hpp" #include "servers.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_config &server_env, std::string user); // 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_config &mServerEnv; std::string mUser; }; bool rsync_tree_to_remote( const std::string &local_path, const std::string &remote_path, const server_config &server_env, bool silent, std::string user); std::string get_arch(); std::map get_all_services_status(const server_config & server_env); std::map get_all_services_status(const server_config & server_env, std::string user); 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_config &server_env, const std::string &local_path, const std::string &remote_path, bool silent, std::string user); bool scp_file_from_remote(const server_config &server_env, const std::string &remote_path, const std::string &local_path, bool silent, std::string user); // defined in backupdata.cpp, used by restoredata.cpp. bool backupdata_service(const server_config &server_env, const std::string& service); // defined in uninstall.cpp bool uninstall_service(const server_config &server_env, 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 server_config &server_env, 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, std::string user_override=""); bool merge_updated_service_template(const std::string &server_name, const std::string &service_name); } // namespace shared_commands } // namespace dropshell #endif