X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Ftemplate%2Finspircd;h=c4e5bd202d43587573e3f7e1bed36f3bcb3c6caf;hb=b64fe8320ecbcc3f6099a3c0ae1b2739447bfc76;hp=8405c2a6b8fbf6400b1d81227bb3115d40878af1;hpb=6fe1f4e1136f2ab95a88e68af1894bf6002d03f4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/template/inspircd b/make/template/inspircd index 8405c2a6b..c4e5bd202 100644 --- a/make/template/inspircd +++ b/make/template/inspircd @@ -1,10 +1,23 @@ %mode 0750 #!/usr/bin/env perl - # # InspIRCd -- Internet Relay Chat Daemon # +# Copyright (C) 2015 Steven Van Acker +# Copyright (C) 2015 Attila Molnar +# Copyright (C) 2014 Dan Parsons +# Copyright (C) 2013-2014, 2016-2019 Sadie Powell +# Copyright (C) 2012 Robby +# Copyright (C) 2012 Adam +# Copyright (C) 2011 DjSlash # Copyright (C) 2009-2010 Daniel De Graaf +# Copyright (C) 2008-2009 Robin Burchell +# Copyright (C) 2008 Thomas Stagner +# Copyright (C) 2007 Dennis Friis +# Copyright (C) 2006 Oliver Lupton +# Copyright (C) 2006 John Brooks +# Copyright (C) 2005-2006, 2008-2009 Craig Edwards +# Copyright (C) 2005 Craig McLure # # 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,17 +61,34 @@ use constant { GENERIC_EXIT_NOT_RUNNING => 7 }; +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@"; my $valgrindlogpath = "$basepath/valgrindlogs"; my $executable = "inspircd"; -my $version = "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@+@VERSION_LABEL@"; +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; @@ -87,7 +117,7 @@ for my $a (@ARGV) } } if (!defined $conf) { - $conf = $confpath . "inspircd.conf"; + $conf = expand_fragment $confpath, "inspircd.conf"; push @ARGV, '--config='.$conf; } @@ -153,7 +183,7 @@ sub cmd_rehash() sub cmd_cron() { - if (getstatus() == 0) { goto &cmd_start(); } + if (getstatus() == 0) { goto &cmd_start(@_); } exit GENERIC_EXIT_UNSPECIFIED; } @@ -167,7 +197,7 @@ sub cmd_restart(@) { cmd_stop(); unlink($pidfile) if (-e $pidfile); - goto &cmd_start; + goto &cmd_start(@_); } sub hid_cheese_sandwich() @@ -203,7 +233,7 @@ sub dev_debug(@) checkgdb(); # If we are still alive here.. Try starting the IRCd.. - exec 'gdb', "--command=$basepath/.gdbargs", '--args', "$binpath/$executable", qw(--nofork --debug), @_; + exec 'gdb', @gdbargs, @_; die "Failed to start GDB: $!\n"; } @@ -222,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=$basepath/.gdbargs", '-args', "$binpath/$executable", qw(--nofork --debug --nolog), @_; + exec qw(screen -m -d gdb), @gdbargs, @_; die "Failed to start screen: $!\n"; } @@ -242,7 +272,7 @@ sub dev_valdebug(@) # If we are still alive here.. Try starting the IRCd.. # May want to do something with these args at some point: --suppressions=.inspircd.sup --gen-suppressions=yes # Could be useful when we want to stop it complaining about things we're sure aren't issues. - exec qw(valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=10), "$binpath/$executable", qw(--nofork --debug --nolog), @_; + exec qw(valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=30), "$binpath/$executable", qw(--nofork --debug --nolog), @_; die "Failed to start valgrind: $!\n"; } @@ -276,7 +306,7 @@ sub dev_valdebug_unattended(@) sysopen STDERR, "$valgrindlogpath/valdebug.$suffix", O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND, 0666 or die "Can't open $valgrindlogpath/valdebug.$suffix: $!\n"; # May want to do something with these args at some point: --suppressions=.inspircd.sup --gen-suppressions=yes # Could be useful when we want to stop it complaining about things we're sure aren't issues. - exec qw(valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=15 --track-fds=yes), + exec qw(valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=30 --track-fds=yes), "--suppressions=$binpath/valgrind.sup", qw(--gen-suppressions=all), qw(--leak-resolution=med --time-stamp=yes --log-fd=2 --), "$binpath/$executable", qw(--nofork --debug --nolog), @_; @@ -301,7 +331,7 @@ sub dev_screenvaldebug(@) # 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 valgrind and 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 valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=10), "$binpath/$executable", qw(--nofork --debug --nolog), @_; + exec qw(screen -m -d valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=30), "$binpath/$executable", qw(--nofork --debug --nolog), @_; die "Failed to start screen: $!\n"; } @@ -311,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; @@ -350,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}; @@ -376,16 +404,7 @@ sub getpidfile if (($i =~ //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; } }