For those that want an rc script for slackware, here is one written in perl:
Code:
#!/usr/bin/perl
# Start the Clam antivirus demon
if ($#ARGV != 0 || $ARGV[0] !~ /^(start|stop|restart|status)$/)
{
print "Usage: $0 start|stop|restart|status\n";
exit 1;
}
$_ = $1;
our $pid_file = "/var/run/clamd.pid";
&start(), exit 0 if /^start$/;
&stop(), exit 0 if /^stop$/;
&restart(), exit 0 if /^restart$/;
&status(), exit 0 if /^status$/;
sub get_pid
{
return 0 unless -f $pid_file;
$pid = `cat $pid_file`;
return 0 unless kill 0, $pid;
return $pid;
}
sub start
{
if (&get_pid)
{
print "ClamAV is already running\n";
exit 1;
}
print "Starting ClamAV...\n";
exec "/usr/sbin/clamd";
}
sub stop
{
if ($id = &get_pid())
{
print "Stopping ClamAV [PID: $id]\n";
system "kill $id";
}
else
{
print "ClamAV is not running\n";
exit 1;
}
}
sub restart
{
&stop();
wait;
&start();
}
sub status
{
if ($id = &get_pid())
{
print "ClamAV is running [PID: $id]\n";
}
else
{
print "ClamAV is not running\n";
}
}