Browse Source

added ngircd-ctl script

master
gashapwn 3 years ago
parent
commit
bd187d6964
1 changed files with 32 additions and 0 deletions
  1. +32
    -0
      perl-script/ngircd-ctl.pl

+ 32
- 0
perl-script/ngircd-ctl.pl View File

@@ -0,0 +1,32 @@
#!/usr/bin/perl

use warnings;
use strict;

my @MY_ARGV = @ARGV;
my $MY_ACMD = shift;

my $NGIRCD='ngircd';
my $NGIRCD_UID = 703;
my $NGIRCD_UN = "_ngircd";

my $ERROR = 0;

my $USAGE = "Usage: ngircd-ctl (start|status|stop)";
my $PERM_ERR = "must run as $NGIRCD_UN\nplease run using: doas -u $NGIRCD_UN\n";
unless( getpwuid( $< ) =~ /$NGIRCD_UN/ ){
die $PERM_ERR;
}

if ($MY_ACMD eq "stop"){
$ERROR = system("pkill -u $NGIRCD_UID -x $NGIRCD");
}elsif($MY_ACMD eq "start"){
$ERROR = system("$NGIRCD");
}elsif($MY_ACMD eq "status"){
$ERROR = system("rcctl check $NGIRCD");
}elsif($MY_ACMD eq "help"){
printf("$USAGE\n");
}else{
printf("$USAGE\n");
}

Loading…
Cancel
Save