+%mode 0750
#!/usr/bin/env perl
-# +------------------------------------+
-# | Inspire Internet Relay Chat Daemon |
-# +------------------------------------+
+
+#
+# InspIRCd -- Internet Relay Chat Daemon
+#
+# Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
#
-# InspIRCd: (C) 2002-2010 InspIRCd Development Team
-# See: http://wiki.inspircd.org/Credits
+# 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
+# License as published by the Free Software Foundation, version 2.
#
-# This program is free but copyrighted software; see
-# the file COPYING for details.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
#
-# ---------------------------------------------------
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+
+
use strict;
use POSIX;
use Fcntl;
my $confpath = "@CONFIG_DIR@/";
my $binpath = "@BINARY_DIR@";
my $runpath = "@BASE_DIR@";
+my $datadir = "@DATA_DIR@";
my $valgrindlogpath = "$basepath/valgrindlogs";
-my $executable = "@EXECUTABLE@";
-my $version = "@VERSION@";
+my $executable = "inspircd";
+my $version = "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@+@VERSION_LABEL@";
my $uid = "@UID@";
-if ($< == 0 || $> == 0) {
+if (!("--runasroot" ~~ @ARGV) && ($< == 0 || $> == 0)) {
if ($uid !~ /^\d+$/) {
# Named UID, look it up
$uid = getpwnam $uid;
}
# End of includes / No includes found. Using default.
- $pidfile = $runpath . "/data/inspircd.pid";
+ $pidfile = $datadir . "/inspircd.pid";
}
sub getstatus {
my $pid = getprocessid();
return 0 if $pid == 0;
- return kill 0, $1;
+ return kill 0, $pid;
}
open PIDFILE, '<', $pidfile or return 0;
while(<PIDFILE>)
{
- /(\d+)/ and $pid = $1;
+ /^(\d+)$/ and $pid = $1;
}
close PIDFILE;
return $pid;