From 29054912680f4f66a84ac947de38b8e99a1c4d80 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Mar 2021 11:25:53 -0500 Subject: [PATCH] This wraps up the ctdlmigrate fixes. --- citadel/ctdlmigrate.c | 33 +++++++++------ citadel/modules/ctdlproto/serv_syscmds.c | 52 +++++++++--------------- 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/citadel/ctdlmigrate.c b/citadel/ctdlmigrate.c index d18707a27..5d8601179 100644 --- a/citadel/ctdlmigrate.c +++ b/citadel/ctdlmigrate.c @@ -37,7 +37,7 @@ #include "citadel_dirs.h" -// yeah, this wouldn't work in a multithreaded program. +// support for getz() -- (globals would not be appropriate in a multithreaded program) static int gmaxlen = 0; static char *gdeftext = NULL; @@ -304,7 +304,7 @@ int main(int argc, char *argv[]) { getz(yesno, 1, NULL, "Do you wish to continue? "); puts(yesno); if (tolower(yesno[0]) != 'y') { - cmdexit = 1; + cmdexit = 101; } if (!cmdexit) { @@ -321,7 +321,7 @@ int main(int argc, char *argv[]) { printf("Checking connectivity to Citadel in %s...\n", ctdldir); local_admin_socket = uds_connectsock("citadel-admin.socket"); if (local_admin_socket < 0) { - cmdexit = 1; + cmdexit = 102; } } @@ -329,7 +329,7 @@ int main(int argc, char *argv[]) { serv_gets(local_admin_socket, buf); puts(buf); if (buf[0] != '2') { - cmdexit = 1; + cmdexit = 103; } } @@ -338,7 +338,7 @@ int main(int argc, char *argv[]) { serv_gets(local_admin_socket, buf); puts(buf); if (buf[0] != '2') { - cmdexit = 1; + cmdexit = 104; } } @@ -352,7 +352,7 @@ int main(int argc, char *argv[]) { remote_server_socket = tcp_connectsock(remote_host, remote_port); if (remote_server_socket < 0) { - cmdexit = 1; + cmdexit = 105; } } @@ -360,7 +360,7 @@ int main(int argc, char *argv[]) { serv_gets(remote_server_socket, buf); puts(buf); if (buf[0] != '2') { - cmdexit = 1; + cmdexit = 106; } } @@ -369,7 +369,7 @@ int main(int argc, char *argv[]) { serv_gets(remote_server_socket, buf); puts(buf); if (buf[0] != '3') { - cmdexit = 1; + cmdexit = 107; } } @@ -378,7 +378,7 @@ int main(int argc, char *argv[]) { serv_gets(remote_server_socket, buf); puts(buf); if (buf[0] != '2') { - cmdexit = 1; + cmdexit = 108; } } @@ -402,7 +402,7 @@ int main(int argc, char *argv[]) { serv_gets(remote_server_socket, buf); if (buf[0] != '1') { printf("\n\033[31m%s\033[0m\n", buf); - cmdexit = 3; + cmdexit = 109; } } @@ -411,7 +411,7 @@ int main(int argc, char *argv[]) { serv_gets(local_admin_socket, buf); if (buf[0] != '4') { printf("\n\033[31m%s\033[0m\n", buf); - cmdexit = 3; + cmdexit = 110; } } @@ -439,10 +439,17 @@ int main(int argc, char *argv[]) { if ( (cmdexit == 0) && (progress < 100) ) { printf("\033[31mERROR: source stream ended before 100 percent of data was received.\033[0m\n"); - ctdlmigrate_exit(86); + cmdexit = 111; } - // FIXME restart the local server here + if (!cmdexit) { + printf("\033[36mMigration is complete. Restarting the target server.\033[0m\n"); + serv_puts(local_admin_socket, "DOWN 1"); + serv_gets(local_admin_socket, buf); + puts(buf); + printf("\033[36mIt is recommended that you shut down the source server now.\033[0m\n"); + printf("\033[36mRemember to copy over your SSL keys and file libraries if appropriate.\033[0m\n"); + } close(remote_server_socket); close(local_admin_socket); diff --git a/citadel/modules/ctdlproto/serv_syscmds.c b/citadel/modules/ctdlproto/serv_syscmds.c index 8783cc291..28e2ea606 100644 --- a/citadel/modules/ctdlproto/serv_syscmds.c +++ b/citadel/modules/ctdlproto/serv_syscmds.c @@ -1,17 +1,14 @@ - -/* - * Main source module for the Citadel server - * - * Copyright (c) 1987-2018 by the citadel.org team - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// System management commands for Citadel server +// +// Copyright (c) 1987-2021 by the citadel.org team +// +// This program is open source software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. #include #include @@ -20,16 +17,13 @@ #include "ctdl_module.h" -/* - * Shut down the server - */ +// Shut down or restart the server void cmd_down(char *argbuf) { char *Reply ="%d Shutting down server. Goodbye.\n"; if (CtdlAccessCheck(ac_aide)) return; - if (!IsEmptyStr(argbuf)) - { + if (!IsEmptyStr(argbuf)) { int state = CIT_OK; restart_server = extract_int(argbuf, 0); @@ -46,11 +40,8 @@ void cmd_down(char *argbuf) { } -/* - * Halt the server without exiting the server process. - */ +// Halt the server without exiting the server process. void cmd_halt(char *argbuf) { - if (CtdlAccessCheck(ac_aide)) return; cprintf("%d Halting server. Goodbye.\n", CIT_OK); @@ -59,11 +50,8 @@ void cmd_halt(char *argbuf) { } -/* - * Schedule or cancel a server shutdown - */ -void cmd_scdn(char *argbuf) -{ +// Schedule or cancel a server shutdown +void cmd_scdn(char *argbuf) { int new_state; int state = CIT_OK; char *Reply = "%d %d\n"; @@ -83,9 +71,9 @@ void cmd_scdn(char *argbuf) } -/*****************************************************************************/ -/* MODULE INITIALIZATION STUFF */ -/*****************************************************************************/ +// **************************************************************************** +// * MODULE INITIALIZATION STUFF * +// **************************************************************************** CTDL_MODULE_INIT(syscmd) { @@ -94,6 +82,6 @@ CTDL_MODULE_INIT(syscmd) CtdlRegisterProtoHook(cmd_halt, "HALT", "halt the server without exiting the server process"); CtdlRegisterProtoHook(cmd_scdn, "SCDN", "schedule or cancel a server shutdown"); } - /* return our id for the Log */ + // return our id for the log return "syscmd"; } -- 2.30.2