*--------------------------------------------------------------------------*/
enum {
BOOT_DEBUG = 1,
- BOOT_TTY = 2
+ BOOT_TTY = 2,
+ BOOT_CHKCONF = 4
};
log_close();
- close_connections(!(thisServer.bootopt & (BOOT_TTY | BOOT_DEBUG)));
+ close_connections(!(thisServer.bootopt & (BOOT_TTY | BOOT_DEBUG | BOOT_CHKCONF)));
execv(SPATH, thisServer.argv);
Debug((DEBUG_NOTICE, "Connection check at : %s", myctime(CurrentTime)));
for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
/* Also when already connecting! (update holdtimes) --SRB */
- if (!(aconf->status & CONF_SERVER) || aconf->port == 0 || aconf->hold == 0)
+ if (!(aconf->status & CONF_SERVER) || aconf->address.port == 0 || aconf->hold == 0)
continue;
/* Also skip juped servers */
* debugmode
*--------------------------------------------------------------------------*/
static void parse_command_line(int argc, char** argv) {
- const char *options = "d:f:h:ntvx:";
+ const char *options = "d:f:h:nktvx:";
int opt;
if (thisServer.euid != thisServer.uid)
*/
while ((opt = getopt(argc, argv, options)) != EOF)
switch (opt) {
+ case 'k': thisServer.bootopt |= BOOT_CHKCONF; break;
case 'n':
case 't': thisServer.bootopt |= BOOT_TTY; break;
case 'd': dpath = optarg; break;
break;
default:
- printf("Usage: ircd [-f config] [-h servername] [-x loglevel] [-ntv]\n");
- printf("\n -n -t\t Don't detach\n -v\t display version\n\n");
+ printf("Usage: ircd [-f config] [-h servername] [-x loglevel] [-ntvk]\n");
+ printf("\n -n -t\t Don't detach\n -v\t display version\n -k\t exit after checking config\n\n");
printf("Server not started.\n");
exit(1);
}
* daemon_init
*--------------------------------------------------------------------------*/
static void daemon_init(int no_fork) {
- if (!init_connection_limits())
- exit(9);
-
- close_connections(!(thisServer.bootopt & (BOOT_DEBUG | BOOT_TTY)));
-
if (no_fork)
return;
!check_file_access(configfile, 'C', R_OK))
return 4;
- debug_init(thisServer.bootopt & BOOT_TTY);
- daemon_init(thisServer.bootopt & BOOT_TTY);
+ if (!init_connection_limits())
+ return 9;
+
+ close_connections(!(thisServer.bootopt & (BOOT_DEBUG | BOOT_TTY | BOOT_CHKCONF)));
+
event_init(MAXCONNECTIONS);
setup_signals();
feature_init(); /* initialize features... */
log_init(*argv);
set_nomem_handler(outofmemory);
-
+
if (!init_string()) {
log_write(LS_SYSTEM, L_CRIT, 0, "Failed to initialize string module");
return 6;
return 7;
}
+ if(thisServer.bootopt & BOOT_CHKCONF) {
+ fprintf(stderr, "Configuration file checked okay.\n");
+ return 0;
+ }
+
+ debug_init(thisServer.bootopt & BOOT_TTY);
+ daemon_init(thisServer.bootopt & BOOT_TTY);
if (check_pid()) {
Debug((DEBUG_FATAL, "Failed to acquire PID file lock after fork"));
exit(2);