lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
fflush(stdout); fflush(stderr);
+ if (restart_server != 0)
+ exit(1);
exit(exitcode);
}
/*
* Shut down the server
*/
-void cmd_down(void) {
+void cmd_down(char *argbuf) {
+ char *Reply ="%d Shutting down server. Goodbye.\n";
if (CtdlAccessCheck(ac_aide)) return;
- cprintf("%d Shutting down server. Goodbye.\n", CIT_OK);
+ if (!IsEmptyStr(argbuf))
+ {
+ int state = CIT_OK;
+ restart_server = extract_int(argbuf, 0);
+
+ if (restart_server > 0)
+ Reply = "%d Restarting server. See you soon.\n";
+ if ((restart_server > 0) && !running_as_daemon)
+ {
+ lprintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
+ Reply = "%d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
+ state = ERROR;
+ }
+ cprintf(Reply, state);
+ }
+ else
+ {
+ cprintf(Reply, CIT_OK);
+ }
time_to_die = 1;
}
}
else if (!strncasecmp(cmdbuf,"DOWN",4)) {
- cmd_down();
+ cmd_down(&cmdbuf[5]);
}
else if (!strncasecmp(cmdbuf,"HALT",4)) {
void cmd_more (void);
void cmd_echo (char *etext);
void cmd_ipgm (char *argbuf);
-void cmd_down (void);
+void cmd_down (char *argbuf);
void cmd_halt (void);
void cmd_scdn (char *argbuf);
void cmd_extn (char *argbuf);
#include "snprintf.h"
#endif
-int running_as_daemon = 0;
-
/*
* Here's where it all begins.
*/
int syslog_facility = LOG_DAEMON;
int enable_syslog = 0;
-extern int running_as_daemon;
void DestroyWorkerList(void);
volatile int time_to_die = 0;
volatile int shutdown_and_halt = 0;
+volatile int restart_server = 0;
+volatile int running_as_daemon = 0;
static RETSIGTYPE signal_cleanup(int signum) {
lprintf(CTDL_DEBUG, "Caught signal %d; shutting down.\n", signum);
extern int num_sessions;
extern volatile int time_to_die;
extern volatile int shutdown_and_halt;
+extern volatile int running_as_daemon;
+extern volatile int restart_server;
extern int verbosity;
extern int rescan[];
#define strcasecmp(x,y) strncasecmp(x,y,INT_MAX);
#endif
+#define IsEmptyStr(a) ((a)[0] == '\0')
+
#define num_parms(source) num_tokens(source,(char)'|')
void stripout(char *str, char leftboundary, char rightboundary);
void stripallbut(char *str, char leftboundary, char rightboundary);