Server ssh works!!

This commit is contained in:
Your Name
2025-04-25 22:00:41 +12:00
parent 1d8502d71a
commit 5d7a22794d
6 changed files with 84 additions and 23 deletions

View File

@ -20,14 +20,10 @@ void print_help() {
std::cout << std::endl;
std::cout << "A tool for managing server configurations" << std::endl;
std::cout << std::endl;
std::cout << "dropshell ..." << std::endl;
std::cout << " help Show this help message" << std::endl;
std::cout << " version Show version information" << std::endl;
std::cout << " init DIR Add a local dropshell config directory (you can add several)" << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << "Server commands:" << std::endl;
std::cout << " servers Summary of all configured servers" << std::endl;
std::cout << " servers NAME Show details for specific server" << std::endl;
std::cout << " init DIR Add DIR as a local configuration directory for dropshell (can add several)" << std::endl;
std::cout << " server NAME Show details for specific server" << std::endl;
std::cout << " templates List all available templates" << std::endl;
std::cout << std::endl;
std::cout << std::endl;
@ -35,8 +31,9 @@ void print_help() {
std::cout << " install SERVER [SERVICE] Install/reinstall/update service(s). Non-destructive." << std::endl;
std::cout << " COMMAND SERVER [SERVICE] Run a command on service(s)." << std::endl;
std::cout << std::endl;
std::cout << "Standard commands: install, backup, uninstall, start, stop" << std::endl;
std::cout << "Standard commands: install, uninstall, backup, restore, start, stop" << std::endl;
std::cout << std::endl;
std::cout << " ssh SERVER [SERVICE] Launch an interactive shell on a server or service" << std::endl;
std::cout << std::endl;
std::cout << "Creation commands: (apply to the first local config directory)"<<std::endl;
std::cout << " create-template TEMPLATE" << std::endl;
@ -132,7 +129,7 @@ int main(int argc, char* argv[]) {
});
if (cfg->is_config_set())
commands.merge(std::set<std::string>{
"servers","templates","create-service","create-template","create-server"
"server","templates","create-service","create-template","create-server","ssh"
});
for (const auto& command : commands) {
@ -183,7 +180,7 @@ int main(int argc, char* argv[]) {
return 0;
}
if (cmd == "servers") {
if (cmd == "server") {
if (argc > 2) {
// Show details for specific server
dropshell::show_server_details(argv[2]);
@ -226,6 +223,16 @@ int main(int argc, char* argv[]) {
return 0;
}
if (cmd == "ssh" && argc < 4) {
if (argc < 3)
{
std::cerr << "Error: ssh requires a server name and optionally service name" << std::endl;
return 1;
}
dropshell::interactive_ssh(argv[2], "");
return 0;
}
// handle running a command.
for (const auto& command : commands) {
if (cmd == command) {