33 lines
678 B
Perl
33 lines
678 B
Perl
|
#!/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");
|
||
|
}
|