All pastes #334862 Raw Edit

Stuff

public text v1 · immutable
#334862 ·published 2007-01-31 22:52 UTC
rendered paste body
#!/usr/bin/perl.real
# Game Server Module, crontab     Copyright(c) cPanel, Inc.
#                                 All rights Reserved.
# darren@cpanel.net               http://cpgs.cpanel.net

$arg=$ARGV[0];

if($arg eq "-v") { $verbose=1; }

open(CONFIG,"</var/cpanel/cpgsd.cfg") or die print "Could not open config file /var/cpanel/cpgsd.cfg : $!\n";
while(<CONFIG>) {
s/(\r|\n)//g;
my($var,$val)=split(/\=/,$_,2);
 if($var eq "root") { $root=$val; last; }
}
close(CONFIG);

if(-e "$root/cpgsd.pid") {
open(TM,"<$root/cpgsd.pid");
my $formerpid = (<TM>);
close(TM);

my @procs=`ps uaxww`;
 foreach my $pr(@procs) {
  my(undef,$ppid,$rest)=split(/\s+/,$pr,3);
  if(($ppid == $formerpid) and ($rest =~ /cPGSD/)) {
          if($verbose) { $rest =~ s/(\r|\n)//g; print "cPGSD is currently running. $ppid [$rest]"; }
          exit(0);
  }
 }
}

# if we get this far, we didn't find cPGSD running already

$ret = system("/var/cpanel/cpgsd.pl 2>\&1 >/dev/null");

if($verbose) {
 if($ret == 0) {
        print "cPGSD not running, restarted.. ";
        } else {
        print "cPGSD not running, nor could it be restarted. Please run /var/cpanel/cpgsd.pl manually for errors.";
        }

}