#!/usr/local/bin/perl
# restart.cgi
# Stop and then restart the Jabber server

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

if ($config{'stop_cmd'}) {
	&system_logged("$config{'stop_cmd'} </dev/null >/dev/null 2>&1");
	}
else {
	if (open(PID, &jabber_pid_file()) && ($pid = int(<PID>)) &&
	    &kill_logged('TERM', $pid)) {
		# Stopped ok ..
		}
	else {
		&error("<tt>$!</tt>");
		}
	}
unlink(&jabber_pid_file());

&system_logged("$config{'start_cmd'} </dev/null >/tmp/err 2>&1");
&webmin_log("restart");
&redirect("");

