#!/usr/local/bin/perl
# stop_hostsentry.cgi
# Stop hostsentry daemon

require './sentry-lib.pl';
&error_setup($text{'hostsentry_stoperr'});

if ($config{'hostsentry_stop'}) {
	$out = &backquote_logged("($config{'hostsentry_stop'}) 2>&1 </dev/null");
	&error("<tt>$out</tt>") if ($out =~ /error|failed/i);
	}
else {
	$pid = &get_hostsentry_pid();
	if ($pid) {
		&kill_logged("TERM", $pid) ||
			&error(&text('hostsentry_ekill', $pid, $!));
		}
	else {
		&error($text{'hostsentry_estopped'});
		}
	}
&webmin_log("stop", "hostsentry");

&redirect("edit_hostsentry.cgi");

