]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/template/inspircd
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / make / template / inspircd
index d0978ee295dd71a24487c35065a0858b929d1664..213f78043e254d2126dce60a5ff3303c269a107f 100644 (file)
@@ -1,10 +1,22 @@
 %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-2021 Sadie Powell <sadie@witchery.services>
+#   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+#   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
@@ -49,16 +61,21 @@ use constant {
 };
 
 my $scriptpath = "@SCRIPT_DIR@";
-my $basepath   =       "@BASE_DIR@";
 my $confpath   =       "@CONFIG_DIR@";
 my $binpath    =       "@BINARY_DIR@";
-my $runpath    =       "@BASE_DIR@";
-my $datadir    =       "@DATA_DIR@";
-my $valgrindlogpath    =       "$basepath/valgrindlogs";
+my $runtimedir = "@RUNTIME_DIR@";
+my $valgrindlogpath = "@LOG_DIR@/valgrind";
 my $executable =       "inspircd";
 my $version    =       "@VERSION_FULL@";
 my $uid = "@UID@";
 
+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 =~ /^\//) {
@@ -129,8 +146,8 @@ sub cmd_help()
        my @cmds = grep /^cmd_/, @subs;
        my @devs = grep /^dev_/, @subs;
        local $_;
-       $_ =~ s/^(cmd|dev)_// foreach (@cmds, @devs);
-       $_ =~ s/_/-/g foreach (@cmds, @devs);
+       $_ =~ s/^(cmd|dev)_// for (@cmds, @devs);
+       $_ =~ s/_/-/g for (@cmds, @devs);
        print STDERR "Usage: ./inspircd (" . join("|", @cmds) . ")\n";
        print STDERR "Developer arguments: (" . join("|", @devs) . ")\n";
        exit GENERIC_EXIT_SUCCESS;
@@ -152,7 +169,7 @@ sub cmd_rehash()
 {
        if (getstatus() == 1) {
                my $pid = getprocessid();
-               system("kill -HUP $pid >/dev/null 2>&1");
+               kill HUP => $pid;
                print "InspIRCd rehashed (pid: $pid).\n";
                exit GENERIC_EXIT_SUCCESS;
        } else {
@@ -191,8 +208,8 @@ sub cmd_start(@)
 {
        # Check to see its not 'running' already.
        if (getstatus() == 1) { print "InspIRCd is already running.\n"; exit GENERIC_EXIT_SUCCESS; }
+
        # If we are still alive here.. Try starting the IRCd..
-       chdir $runpath;
        print "$binpath/$executable doesn't exist\n" and return 0 unless(-e "$binpath/$executable");
        print "$binpath/$executable is not executable\n" and return 0 unless(-f "$binpath/$executable" && -x "$binpath/$executable");
 
@@ -205,7 +222,6 @@ sub dev_debug(@)
        # Check to see its not 'running' already.
        if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
 
-       chdir $runpath;
        print "$binpath/$executable doesn't exist\n" and return 0 unless(-e "$binpath/$executable");
        print "$binpath/$executable is not executable\n" and return 0 unless(-f "$binpath/$executable" && -x "$binpath/$executable");
 
@@ -213,7 +229,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";
 }
 
@@ -222,7 +238,6 @@ sub dev_screendebug(@)
        # Check to see its not 'running' already.
        if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
 
-       chdir $runpath;
        print "$binpath/$executable doesn't exist\n" and return 0 unless(-e "$binpath/$executable");
 
        #Check we have gdb
@@ -232,7 +247,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";
 }
 
@@ -241,7 +256,6 @@ sub dev_valdebug(@)
        # Check to see its not 'running' already.
        if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
 
-       chdir $runpath;
        print "$binpath/$executable doesn't exist\n" and return 0 unless(-e "$binpath/$executable");
        print "$binpath/$executable is not executable\n" and return 0 unless(-f "$binpath/$executable" && -x "$binpath/$executable");
 
@@ -262,7 +276,6 @@ sub dev_valdebug_unattended(@)
        # Check to see its not 'running' already.
        if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
 
-       chdir $runpath;
        print "$binpath/$executable doesn't exist\n" and return 0 unless(-e "$binpath/$executable");
        print "$binpath/$executable is not executable\n" and return 0 unless(-f "$binpath/$executable" && -x "$binpath/$executable");
 
@@ -299,7 +312,6 @@ sub dev_screenvaldebug(@)
        # Check to see its not 'running' already.
        if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
 
-       chdir $runpath;
        print "$binpath/$executable doesn't exist\n" and return 0 unless(-e "$binpath/$executable");
        print "$binpath/$executable is not executable\n" and return 0 unless(-f "$binpath/$executable" && -x "$binpath/$executable");
 
@@ -339,18 +351,6 @@ sub cmd_stop()
 # Generic Helper Functions.
 ###
 
-# GetPidfile Version 2 - Now With Include Support..
-# I beg for months for include support in insp, then..
-# when it is added, it comes around and BITES ME IN THE ASS,
-# because i then have to code support into this script.. Evil.
-
-# Craig got bitten in the ass again --
-# in 1.1 beta the include file is manditory, therefore
-# if we cant find it, default to %conf%/inspircd.pid.
-# Note, this also contains a fix for when the pid file is
-# defined, but defined in a comment (line starts with #)
-# -- Brain
-
 my %filesparsed;
 
 sub getpidfile
@@ -384,7 +384,7 @@ sub getpidfile
                if (($i =~ /<pid file=\"(\S+)\">/i) && ($i !~ /^#/))
                {
                        # Set the PID file and return.
-                       $pidfile = expand_fragment $datadir, $1;
+                       $pidfile = expand_fragment $runtimedir, $1;
                        return;
                }
        }
@@ -406,7 +406,7 @@ sub getpidfile
        }
 
        # End of includes / No includes found. Using default.
-       $pidfile = $datadir . "/inspircd.pid";
+       $pidfile = $runtimedir . "/inspircd.pid";
 }
 
 sub getstatus {