Check status from init script if possible

This commit is contained in:
Jamie Cameron
2024-07-26 19:06:16 -07:00
parent 6f7003965e
commit 615765b995
2 changed files with 5 additions and 0 deletions

View File

@@ -214,6 +214,7 @@ apply_ecannot=You are not allowed to apply the configuration
stop_err=Failed to stop LDAP server stop_err=Failed to stop LDAP server
stop_ecmd=$1 failed : $2 stop_ecmd=$1 failed : $2
stop_egone=No longer running! stop_egone=No longer running!
stop_egone2=Running but PID is unknown!
stop_ekill=Kill process failed : $1 stop_ekill=Kill process failed : $1
stop_ecannot=You are not allowed to stop the LDAP server stop_ecannot=You are not allowed to stop the LDAP server

View File

@@ -526,6 +526,7 @@ if ($config{'stop_cmd'}) {
else { else {
local $pid = &is_ldap_server_running(); local $pid = &is_ldap_server_running();
$pid || return $text{'stop_egone'}; $pid || return $text{'stop_egone'};
$pid > 1 || return $text{'stop_egone2'};
return kill('TERM', $pid) ? undef : &text('stop_ekill', $!); return kill('TERM', $pid) ? undef : &text('stop_ekill', $!);
} }
} }
@@ -564,6 +565,9 @@ else {
# Returns the process ID of the running LDAP server, or undef # Returns the process ID of the running LDAP server, or undef
sub is_ldap_server_running sub is_ldap_server_running
{ {
&foreign_require("init");
my $iname = $config{'init_name'} || $module_name;
return 1 if (&init::status_action($iname) == 1);
local $pidfile = &get_ldap_server_pidfile(); local $pidfile = &get_ldap_server_pidfile();
if ($pidfile) { if ($pidfile) {
return &check_pid_file($pidfile); return &check_pid_file($pidfile);