LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-02-2004, 12:44 PM   #1
arobinson74
Member
 
Registered: Nov 2002
Location: Lone Tree, CO
Distribution: Xubuntu Gutsy
Posts: 174

Rep: Reputation: 30
Post Slackware clamd rc script


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";
    }
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
make install does not install daemons (clamd snortd). Is this a feature of tarball? Emmanuel_uk Linux - Newbie 3 11-15-2005 01:29 AM
Can't connect to UNIX socket /var/run/clamav/clamd shitoryu Linux - Software 1 07-25-2005 12:52 AM
Slackware Startup script CPUFreak91 Linux - Newbie 3 07-19-2005 05:19 PM
Losing clamd-socket carlmarshall Linux - General 0 02-14-2005 04:02 AM
slackware 10 startup script jonc Linux - Newbie 2 12-04-2004 05:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration