]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/template/inspircd
Store generated SSL certificates in the .configure directory.
[user/henk/code/inspircd.git] / make / template / inspircd
index 2ea0a54927277cc11b16262ff45c8d4c2b82c636..c4e5bd202d43587573e3f7e1bed36f3bcb3c6caf 100644 (file)
@@ -1,10 +1,23 @@
 %mode 0750
 #!/usr/bin/env perl
-
 #
 # InspIRCd -- Internet Relay Chat Daemon
 #
+#   Copyright (C) 2015 Steven Van Acker <steven@singularity.be>
+#   Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
+#   Copyright (C) 2014 Dan Parsons <dparsons@nyip.net>
+#   Copyright (C) 2013-2014, 2016-2019 Sadie Powell <sadie@witchery.services>
+#   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+#   Copyright (C) 2012 Adam <Adam@anope.org>
+#   Copyright (C) 2011 DjSlash <djslash@djslash.org>
 #   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+#   Copyright (C) 2008-2009 Robin Burchell <robin+git@viroteck.net>
+#   Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
+#   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+#   Copyright (C) 2006 Oliver Lupton <om@inspircd.org>
+#   Copyright (C) 2006 John Brooks <special@inspircd.org>
+#   Copyright (C) 2005-2006, 2008-2009 Craig Edwards <brain@inspircd.org>
+#   Copyright (C) 2005 Craig McLure <craig@frostycoolslug.com>
 #
 # This file is part of InspIRCd.  InspIRCd is free software: you can
 # redistribute it and/or modify it under the terms of the GNU General Public
@@ -48,9 +61,9 @@ use constant {
     GENERIC_EXIT_NOT_RUNNING => 7
 };
 
-my $scriptpath = "@SCRIPT_DIR@"
+my $scriptpath = "@SCRIPT_DIR@";
 my $basepath   =       "@BASE_DIR@";
-my $confpath   =       "@CONFIG_DIR@/";
+my $confpath   =       "@CONFIG_DIR@";
 my $binpath    =       "@BINARY_DIR@";
 my $runpath    =       "@BASE_DIR@";
 my $datadir    =       "@DATA_DIR@";
@@ -59,7 +72,23 @@ my $executable       =       "inspircd";
 my $version    =       "@VERSION_FULL@";
 my $uid = "@UID@";
 
-if (!("--runasroot" ~~ @ARGV) && ($< == 0 || $> == 0)) {
+my @gdbargs = (
+       '--eval-command', 'handle SIGPIPE pass nostop noprint',
+       '--eval-command', 'handle SIGHUP pass nostop noprint',
+       '--eval-command', 'run',
+       '--args', "$binpath/$executable", qw(--nofork --nolog --debug)
+);
+
+sub expand_fragment($$) {
+       my ($base, $fragment) = @_;
+       if ($fragment =~ /^\//) {
+               return $fragment;
+       } else {
+               return "$base/$fragment";
+       }
+}
+
+if (!(grep { $_ eq '--runasroot' } @ARGV) && ($< == 0 || $> == 0)) {
        if ($uid !~ /^\d+$/) {
                # Named UID, look it up
                $uid = getpwnam $uid;
@@ -88,7 +117,7 @@ for my $a (@ARGV)
        }
 }
 if (!defined $conf) {
-       $conf = $confpath . "inspircd.conf";
+       $conf = expand_fragment $confpath, "inspircd.conf";
        push @ARGV, '--config='.$conf;
 }
 
@@ -204,7 +233,7 @@ sub dev_debug(@)
        checkgdb();
 
        # If we are still alive here.. Try starting the IRCd..
-       exec 'gdb', "--command=$scriptpath/.gdbargs", '--args', "$binpath/$executable", qw(--nofork --debug), @_;
+       exec 'gdb', @gdbargs, @_;
        die "Failed to start GDB: $!\n";
 }
 
@@ -223,7 +252,7 @@ sub dev_screendebug(@)
        # If we are still alive here.. Try starting the IRCd..
        print "Starting InspIRCd in `screen`, type `screen -r` when the ircd crashes to view the gdb output and get a backtrace.\n";
        print "Once you're inside the screen session press ^C + d to re-detach from the session\n";
-       exec qw(screen -m -d gdb), "--command=$scriptpath/.gdbargs", '-args', "$binpath/$executable", qw(--nofork --debug --nolog), @_;
+       exec qw(screen -m -d gdb), @gdbargs, @_;
        die "Failed to start screen: $!\n";
 }
 
@@ -312,7 +341,7 @@ sub cmd_stop()
        # Get to here, we have something to kill.
        my $pid = getprocessid();
        print "Stopping InspIRCd (pid: $pid)...\n";
-       my $maxwait = (`ps -o command $pid` =~ /valgrind/i) ? 90 : 15;
+       my $maxwait = (`ps -o command $pid 2>/dev/null` =~ /valgrind/i) ? 90 : 15;
        kill TERM => $pid or die "Cannot terminate IRCd: $!\n";
        for (1..$maxwait) {
                sleep 1;
@@ -351,11 +380,9 @@ sub getpidfile
        if ($pid ne "") {
                return;
        }
-       # Are We using a relative path?
-       if ($file !~ /^\//) {
-               # Convert it to a full path.
-               $file = $runpath .'/'. $file;
-       }
+
+       # Expand any relative paths.
+       $file = expand_fragment $confpath, $file;
 
        # Have we checked this file before?
        return if $filesparsed{$file};
@@ -377,16 +404,7 @@ sub getpidfile
                if (($i =~ /<pid file=\"(\S+)\">/i) && ($i !~ /^#/))
                {
                        # Set the PID file and return.
-                       $pidfile = $1;
-                       if (-f $pidfile)
-                       {
-                               return;
-                       }
-                       elsif (-f "$runpath/$pidfile")
-                       {
-                               $pidfile = "$runpath/$pidfile";
-                               return;
-                       }
+                       $pidfile = expand_fragment $datadir, $1;
                        return;
                }
        }