From f06ff46151c38b2259c5ee4ae83d38c6f6fc0c8c Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Sun, 12 Jul 2020 02:30:31 +0200 Subject: Teach minecctl to create proper mcserver files, auto-generate systemd service names as necessary --- minecctl/rcon-commands.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'minecctl/rcon-commands.c') diff --git a/minecctl/rcon-commands.c b/minecctl/rcon-commands.c index cb6ea45..cdbf868 100644 --- a/minecctl/rcon-commands.c +++ b/minecctl/rcon-commands.c @@ -96,22 +96,22 @@ static int rcon_login(struct cfg *cfg, struct server *server) assert_die(cfg && server, "invalid arguments"); if (list_empty(&server->scfg.rcons)) { - error("%s: rcon address unknown", server->name); + error("%s: rcon address unknown", server->scfg.name); goto error; } fd = connect_any(&server->scfg.rcons, &saddr, &error); if (fd < 0) { - verbose("%s: unable to connect - %s", server->name, error); + verbose("%s: unable to connect - %s", server->scfg.name, error); goto error; } else - verbose("%s: connected to %s", server->name, saddr->addrstr); + verbose("%s: connected to %s", server->scfg.name, saddr->addrstr); if (!server->scfg.rcon_password) server->scfg.rcon_password = ask_password(); if (!server->scfg.rcon_password) { - error("%s: can't login - password missing", server->name); + error("%s: can't login - password missing", server->scfg.name); goto error; } @@ -123,10 +123,10 @@ static int rcon_login(struct cfg *cfg, struct server *server) if (!rcon_protocol_verify_response(1, 1, RCON_PACKET_LOGIN, rtype, &error)) { - error("%s: invalid response - %s", server->name, error); + error("%s: invalid response - %s", server->scfg.name, error); goto error; } else - verbose("%s: login ok", server->name); + verbose("%s: login ok", server->scfg.name); return fd; @@ -230,7 +230,7 @@ static bool do_one_info(struct cfg *cfg, struct server *server) if (fd < 0) return false; - info("• %s", server->name); + info("• %s", server->scfg.name); if (get_one_status(fd, buf, sizeof(buf), "seed", 1, "Seed : [ %[^]]]", &reply, tbuf)) info(" Seed: %s", tbuf); @@ -336,7 +336,7 @@ static bool stop_one_server(struct cfg *cfg, struct server *server) fd = rcon_login(cfg, server); if (fd < 0) { info("• %s: %sfail%s - unable to login", - server->name, ansi_red, ansi_normal); + server->scfg.name, ansi_red, ansi_normal); return false; } @@ -345,17 +345,17 @@ static bool stop_one_server(struct cfg *cfg, struct server *server) if (!get_player_count(fd, ¤t, NULL)) { info("• %s: %sfail%s - unable to get player count", - server->name, ansi_red, ansi_normal); + server->scfg.name, ansi_red, ansi_normal); return false; } else if (current > 0) { info("• %s: %sfail%s - has active players " "(use -f to force)", - server->name, ansi_red, ansi_normal); + server->scfg.name, ansi_red, ansi_normal); return false; } } - info("• %s: sending stop command", server->name); + info("• %s: sending stop command", server->scfg.name); rv = send_cmd(fd, "stop"); close(fd); @@ -419,9 +419,9 @@ bool do_console(struct cfg *cfg) return false; prompt = alloca(strlen(program_invocation_short_name) + STRLEN(" (") + - strlen(server->name) + STRLEN("): ") + 1); + strlen(server->scfg.name) + STRLEN("): ") + 1); sprintf(prompt, "%s (%s): ", program_invocation_short_name, - server->name); + server->scfg.name); while (true) { char *tmp; -- cgit v1.2.3