]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/template/inspircd
Remove unnecessary chdirs in the helper script.
[user/henk/code/inspircd.git] / make / template / inspircd
index 897a8c81ad2be42ba45d05183ed16f7ae0ea310b..c50d28c7fa0c337f3fa81417085f605be2c949a1 100644 (file)
@@ -1,6 +1,5 @@
 %mode 0750
 #!/usr/bin/env perl
-
 #
 # InspIRCd -- Internet Relay Chat Daemon
 #
@@ -66,8 +65,7 @@ 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 $runtimedir = "@RUNTIME_DIR@";
 my $valgrindlogpath    =       "$basepath/valgrindlogs";
 my $executable =       "inspircd";
 my $version    =       "@VERSION_FULL@";
@@ -150,8 +148,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;
@@ -173,7 +171,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 {
@@ -212,8 +210,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");
 
@@ -226,7 +224,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");
 
@@ -243,7 +240,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
@@ -262,7 +258,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");
 
@@ -283,7 +278,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");
 
@@ -320,7 +314,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");
 
@@ -360,18 +353,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
@@ -405,7 +386,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;
                }
        }
@@ -427,7 +408,7 @@ sub getpidfile
        }
 
        # End of includes / No includes found. Using default.
-       $pidfile = $datadir . "/inspircd.pid";
+       $pidfile = $runtimedir . "/inspircd.pid";
 }
 
 sub getstatus {