Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 17th December 2009, 04:14 AM
csmart Offline
Registered User
 
Join Date: Aug 2009
Posts: 22
linuxfedorafirefox
Script for configuring ClamAV server on Fedora

In short, I’ve written a bash script (available from github) for configuring and removing instances of clamav-server on Fedora (clamd). It lets you create and remove individual instances with a specific user and port (if you specify them) and will install the required packages if not already present on the system and remove them if you want to.

---------------------------------------------
Current version 0.4 - 18th Nov 2010
---------------------------------------------

In long, we use Clam AntiVirus as our antivirus protection for Digital Preservation Recorder and talk to it over the default port, 3310 (clamd).

Installing the clamav-server package under Fedora however, doesn’t actually set up an instance. In fact, it doesn’t copy any system configuration files into place at all. This means that the system is left without any working ClamAV server out of the box.

Under Fedora, ClamAV server is configured on a per user basis. This is actually quite important (unless you run as root) because the daemon needs at minimum read access (and we’ve found also write) on the files/directory being passed for scanning.

The instructions on how to configure it are located under /usr/share/doc/clamav-server-[version]/ but I have taken these instructions and written a bash script to configure all of this for you.

The script is available from github. It can create or remove an individual instance of clamav-server using a specific username and/or port (if you want to specify them, else it defaults to clamav on port 3310). The script will also install any required packages, if you don’t already have them on the system. You also have the option of removing the required packages when you remove an instance.

The script now also configures freshclam for you (the definitions updater), which needs to run as your user too.

Hopefully this is useful to someone else out there and not just us :-) If you find any bugs feel free to let me know.

Last edited by csmart; 18th November 2010 at 09:32 AM. Reason: New version.
Reply With Quote
  #2  
Old 30th December 2009, 01:54 PM
acrobat Offline
Registered User
 
Join Date: Dec 2009
Posts: 4
linuxfedorafirefox
Thanks for this, you've just made my day!
Reply With Quote
  #3  
Old 22nd January 2010, 07:50 AM
zmdmw52's Avatar
zmdmw52 Offline
Registered User
 
Join Date: Dec 2007
Posts: 83
linuxfedorafirefox
Question

Quote:
Originally Posted by csmart View Post
In short, I’ve written a bash script (available from github) for configuring and removing instances of clamav-server on Fedora. It lets you create and remove individual instances with a specific user and port (if you specify them) and will install the required packages if not already present on the system.
On trying to run the script, I get the foll error message:
Code:
[root@LinuxFedora ClamAV_Script]# chmod +x configure-clamd.sh 
[root@LinuxFedora ClamAV_Script]# ./configure-clamd.sh
./configure-clamd.sh: line 8: !DOCTYPE: No such file or directory
./configure-clamd.sh: line 9: syntax error near unexpected token `newline'
./configure-clamd.sh: line 9: `  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
__________________
Linux User 483705 @ http://counter.li.org
Smolt Profile (Fedora 12 Desktop PC)


Reply With Quote
  #4  
Old 29th January 2010, 12:20 AM
cafetono Offline
Registered User
 
Join Date: May 2007
Location: Long Beach, CA
Age: 68
Posts: 39
linuxfedorafirefox
The script "almost" works for me, but . . .(see below) Any suggestions?

su -c './configure-clamd.sh'
Password:

You appear to be running Fedora release 12 (Constantine), excellent.

Configuring clamd to run as user 'clamav' on port '3310'.

If you do NOT want to proceed, hit CTRL+C within 5 seconds...
5.. 4.. 3.. 2.. 1..
OK then, proceeding..

Checking for required packages..
Required packages already installed.

Checking for clamav user, 'clamav'..
User already exists, not creating.

Configuring clamd to do all the right things..
Could not find required template files under /usr/share/doc/clamav-server-sysvinit
0.95.3/, sorry.

Instance of clamd for user 'clamav' NOT created successfully.
Exiting.



But . . . yum reports the following: yum install clamav-server-sysvinit
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Package clamav-server-sysvinit-0.95.3-1200.fc12.noarch already installed and latest version
Nothing to do

Last edited by cafetono; 29th January 2010 at 12:25 AM. Reason: To add pertenent information
Reply With Quote
  #5  
Old 29th July 2010, 12:39 AM
scott32746 Offline
Registered User
 
Join Date: Jun 2007
Location: Lake Mary, Florida
Age: 48
Posts: 1,082
windows_xp_2003firefox
Re: Script for configuring ClamAV server on Fedora

Hello,
I know this is an old post but here is a fix for post #4

Change this line
CLAMD_VERSION="`rpm -qa |grep clamav-server |awk -F "-" {'print $3'} 2>/dev/null`"
to
CLAMD_VERSION="`rpm -qa |grep clamav-server |awk -F "-" {'print $3'} |grep -v [a-z] 2>/dev/null`"
Reply With Quote
  #6  
Old 22nd October 2010, 05:30 AM
csmart Offline
Registered User
 
Join Date: Aug 2009
Posts: 22
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora

Sorry everyone, I didn't get an email telling me that there were replies to my post.

Scott's fix is correct, I have updated this in the script.

-c
Reply With Quote
  #7  
Old 17th November 2010, 05:36 PM
Bad2theBone's Avatar
Bad2theBone Offline
Registered User
 
Join Date: Jan 2007
Location: Lawrenceville, Georgia
Posts: 352
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora

I was originally getting the error that cafetono got, applied the fix that scott32746 mentions so now my output is;

[root@ncc1701 scott]# ./configure-clamd.sh

You appear to be running Fedora release 14 (Laughlin), excellent.

Configuring clamd to run as user 'clamav' on port '3310'.

If you do NOT want to proceed, hit CTRL+C within 5 seconds...
5.. 4.. 3.. 2.. 1..
OK then, proceeding..

Checking for required packages..
Required packages already installed.

Checking for clamav user, 'clamav'..
User already exists, not creating.

Configuring clamd to do all the right things..
Done.

Configuring log rotation for clamd..
Done.

Configuring clamd under syconfig..
Done.

Configuring clamd init script..
Done.

Enabling freshclam, the clamav updater..
Done.

Creating required directories and starting service..
Could not start service, sorry.
Continuing.

Done.

The clamd service has been successfully installed and configured with:
User 'clamav' on port '3310'.

Have fun!

Anyone have any suggestions on how I can fix this?

---------- Post added at 12:36 PM GMT ---------- Previous post was at 11:57 AM GMT ----------

Just tried the newer script and I now get:

[root@ncc1701 scott]# ./configure-clamd.sh

You appear to be running Fedora release 14 (Laughlin), excellent.

su: warning: cannot change directory to /dev/null: Not a directory
./configure-clamd.sh: line 438: unexpected EOF while looking for matching ``'
./configure-clamd.sh: line 510: syntax error: unexpected end of file

Not sure what is going on.
__________________
Hey, I was born confused, what's your excuse?!?!?! :D
AMD Phenom II 965 64 X4, MSI 890FXA-GD70 8 GB (4x2GB) 1600 DDR3 RAM Corsair, Video = AMD HD5770 w/1GB VRAM, SATAIII SSD 1 = 256GB, SATAIII 2 = 600GB, SATAII 3 = 1.0TB, SATAII 4 = 1.0TB, SATAIII 5 = 1.0TB, SATA 7 = ASUS DVD/CD, Corsair HX850W, CoolMaster ATCS840 OS = Fedora 18
Reply With Quote
  #8  
Old 17th November 2010, 06:13 PM
scott32746 Offline
Registered User
 
Join Date: Jun 2007
Location: Lake Mary, Florida
Age: 48
Posts: 1,082
windows_xp_2003firefox
Re: Script for configuring ClamAV server on Fedora

you maybe missing something like " or or fi
On /dev/null you may need > /dev/null
Reply With Quote
  #9  
Old 17th November 2010, 07:54 PM
Bad2theBone's Avatar
Bad2theBone Offline
Registered User
 
Join Date: Jan 2007
Location: Lawrenceville, Georgia
Posts: 352
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora

Ok, so I tried going through the script which I had downloaded from Chris' blog ( https://github.com/csmart/naa/raw/ma...igure-clamd.sh) today and did find a missing ` on line #438 as follows:

Before:
Code:
echo "alias freshclam='freshclam --config-file=$FRESHCLAM_USER_CONF'" >> `cat /etc/passwd |grep ^$CLAMD_USER: |awk -F ":" {'print $6'}`/.bashrc
After:
Code:
echo "alias freshclam='freshclam --config-file=$FRESHCLAM_USER_CONF'" >> `cat /etc/passwd |grep ^$CLAMD_USER: |awk -F ":" {'print $6'}`/.bashrc`
I could not find any errors with any references to /dev/null all instances of it was preceded by either &> or 2> and the warning text makes it sound like the script is trying to do a cd /dev/null which I could not find anywhere in the script.

As far as the error on line #510, when I open the script up in an editor there are only 509 lines. My bash scripting is very limited so I'm not sure what is wrong.

---------- Post added at 02:54 PM GMT ---------- Previous post was at 02:17 PM GMT ----------

either way I can't get clamd to run and it shows up as a failure in boot messages.
__________________
Hey, I was born confused, what's your excuse?!?!?! :D
AMD Phenom II 965 64 X4, MSI 890FXA-GD70 8 GB (4x2GB) 1600 DDR3 RAM Corsair, Video = AMD HD5770 w/1GB VRAM, SATAIII SSD 1 = 256GB, SATAIII 2 = 600GB, SATAII 3 = 1.0TB, SATAII 4 = 1.0TB, SATAIII 5 = 1.0TB, SATA 7 = ASUS DVD/CD, Corsair HX850W, CoolMaster ATCS840 OS = Fedora 18
Reply With Quote
  #10  
Old 17th November 2010, 10:18 PM
csmart Offline
Registered User
 
Join Date: Aug 2009
Posts: 22
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora

Thanks for reporting that - on line 244 I somehow added a tick in front of the "if" statement - remove this, or pull a new version of the script. Sorry about that, and thanks for letting me know!

The reason the service didn't start the first time you tried is because there were no updates downloaded by freshclam. A new version of the script I committed a few days ago fixes this issue, by also configuring and enabling freshclam.

Freshclam wants to put updates in /var/lib/clamav/ but this is not writable by your user. The script now creates a new freshclam config and location for your updates, so that clamd is running as you, and you can update just by running the "freshclam" command.

Please let me know if that fixes your problems..

Thanks,
-c
Reply With Quote
  #11  
Old 18th November 2010, 03:45 AM
Bad2theBone's Avatar
Bad2theBone Offline
Registered User
 
Join Date: Jan 2007
Location: Lawrenceville, Georgia
Posts: 352
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora

Looks like I'm getting there but not quite.

[root@ncc1701 scott]# ./configure-clamd.sh

You appear to be running Fedora release 14 (Laughlin), excellent.

su: warning: cannot change directory to /dev/null: Not a directory
Configuring clamd to run as user 'clamav' on port '3310'.

If you do NOT want to proceed, hit CTRL+C within 5 seconds...
5.. 4.. 3.. 2.. 1..
OK then, proceeding..

Checking for required packages..
Required packages already installed.

Checking for clamav user, 'clamav'..
User already exists, not creating.

Configuring clamd to do all the right things..
Instance of clamd already exists, clobbering..
Configuring log rotation for clamd..
Configuring clamd under syconfig..
Configuring clamd init script..
Configuring freshclam, the clamav updater..
./configure-clamd.sh: line 440: /dev/null/.bashrc: Not a directory
sed: -e expression #1, char 43: unterminated `s' command
Configuring required directories..
Downloading virus definitions..

This account is currently not available.

WARNING: Could not download definitions, service will fail to start. Continuing.


Creating required directories and starting service..
Could not start service, sorry. Continuing.


================================================== =====================
The clamd service has been successfully installed and configured with:
User 'clamav' on port '3310'.

To update ClamAV definitions, run the 'freshclam' command as user clamav.
================================================== =====================

Have fun!

[root@ncc1701 scott]# freshclam
ClamAV update process started at Wed Nov 17 22:27:23 2010
main.cld is up to date (version: 53, sigs: 846214, f-level: 53, builder: sven)
Downloading daily-12273.cdiff [100%]
Downloading daily-12274.cdiff [100%]
Downloading daily-12275.cdiff [100%]
Downloading daily-12276.cdiff [100%]
Downloading daily-12277.cdiff [100%]
Downloading daily-12278.cdiff [100%]
daily.cld updated (version: 12278, sigs: 6446, f-level: 54, builder: guitar)
Downloading safebrowsing.cvd [100%]
safebrowsing.cvd updated (version: 25090, sigs: 607109, f-level: 53, builder: google)
bytecode.cvd is up to date (version: 91, sigs: 15, f-level: 54, builder: edwin)
Database updated (1459784 signatures) from database.clamav.net (IP: 213.165.80.159)
[root@ncc1701 scott]# logout
[scott@ncc1701 ~]$ freshclam
ERROR: Can't open /var/log/freshclam.log in append mode (check permissions!).
ERROR: Problem with internal logger (UpdateLogFile = /var/log/freshclam.log).
[scott@ncc1701 ~]$ su -
Password:
[root@ncc1701 ~]# cd /home/scott
[root@ncc1701 scott]# ./configure-clamd.sh

You appear to be running Fedora release 14 (Laughlin), excellent.

su: warning: cannot change directory to /dev/null: Not a directory
Configuring clamd to run as user 'clamav' on port '3310'.

If you do NOT want to proceed, hit CTRL+C within 5 seconds...
5.. 4.. 3.. 2.. 1..
OK then, proceeding..

Checking for required packages..
Required packages already installed.

Checking for clamav user, 'clamav'..
User already exists, not creating.

Configuring clamd to do all the right things..
Instance of clamd already exists, clobbering..
Configuring log rotation for clamd..
Configuring clamd under syconfig..
Configuring clamd init script..
Configuring freshclam, the clamav updater..
./configure-clamd.sh: line 440: /dev/null/.bashrc: Not a directory
sed: -e expression #1, char 43: unterminated `s' command
Configuring required directories..
Downloading virus definitions..

This account is currently not available.

WARNING: Could not download definitions, service will fail to start. Continuing.


Creating required directories and starting service..
Could not start service, sorry. Continuing.


================================================== =====================
The clamd service has been successfully installed and configured with:
User 'clamav' on port '3310'.

To update ClamAV definitions, run the 'freshclam' command as user clamav.
================================================== =====================

Have fun!


I didn't see the error on line 440 on the first time before running freshclam as root. I did see it on the second run through and then scrolled back to see it on the first run. Again, my bash scripting capabilities are very limited so I'm not too sure what is actually failing. My best guess is something to do with one of the sed lines prior to 440, but I couldn't see anything.
__________________
Hey, I was born confused, what's your excuse?!?!?! :D
AMD Phenom II 965 64 X4, MSI 890FXA-GD70 8 GB (4x2GB) 1600 DDR3 RAM Corsair, Video = AMD HD5770 w/1GB VRAM, SATAIII SSD 1 = 256GB, SATAIII 2 = 600GB, SATAII 3 = 1.0TB, SATAII 4 = 1.0TB, SATAIII 5 = 1.0TB, SATA 7 = ASUS DVD/CD, Corsair HX850W, CoolMaster ATCS840 OS = Fedora 18
Reply With Quote
  #12  
Old 18th November 2010, 09:30 AM
csmart Offline
Registered User
 
Join Date: Aug 2009
Posts: 22
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora

OK thanks, I think I see the problem. I'll work on a fix and post it asap.

-c

---------- Post added at 08:30 PM GMT ---------- Previous post was at 06:56 PM GMT ----------

OK, I have fixed that issue. Please try version 0.4 from git.

The problem occurs if you create a new user for running clamd. Originally, the script was adding a new system user without a home directory or logon, however when I added the ability to configure freshclam I also try and get the user's proxy settings (if they have them set) it would fail because the user had no home dir or login. Now the script will create a new user with a home dir and logon (so that the updater can be run) - I might have to re-work this as I don't want to introduce a non-system account if I can help it.

Please let me know how that goes!

-c

Last edited by csmart; 18th November 2010 at 09:30 AM.
Reply With Quote
  #13  
Old 18th November 2010, 03:19 PM
Bad2theBone's Avatar
Bad2theBone Offline
Registered User
 
Join Date: Jan 2007
Location: Lawrenceville, Georgia
Posts: 352
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora (resolved)

Chris;

Looks like it may have been something I had done in my attempt to manually get it working. I manually deleted all config files and users/groups created. I then uninstalled all clamav related packages. Then I ran the script and let it install all needed software and configure it. Seems to be fine now. Sorry if I created a problem inadvertently. I had initially did the install myself of all clamav packages, then ran the script. I may have installed too much or the wrong thing. Also I noticed that the new script would not re-create the clamav user once it saw it had already been created, so the clamav directory in /home never got created until it had been manually removed. I don't know if you really need the user created this way or it would still work the other way without login and home directory. If you want, I can try it starting from scratch. I do still have the old version of script (2009) as well as I guess version 0.3 so I can test it later each one and let you know. Let me know if that'll help you.

Again thanks man, it now works like a champ!
__________________
Hey, I was born confused, what's your excuse?!?!?! :D
AMD Phenom II 965 64 X4, MSI 890FXA-GD70 8 GB (4x2GB) 1600 DDR3 RAM Corsair, Video = AMD HD5770 w/1GB VRAM, SATAIII SSD 1 = 256GB, SATAIII 2 = 600GB, SATAII 3 = 1.0TB, SATAII 4 = 1.0TB, SATAIII 5 = 1.0TB, SATA 7 = ASUS DVD/CD, Corsair HX850W, CoolMaster ATCS840 OS = Fedora 18
Reply With Quote
  #14  
Old 18th November 2010, 10:41 PM
csmart Offline
Registered User
 
Join Date: Aug 2009
Posts: 22
linuxfedorafirefox
Re: Script for configuring ClamAV server on Fedora

No, it's not your fault :-)

Although I fixed the bug with the user not having a home directory, you already had a user created from when the script was broken (your clamav user didn't have a home dir, it was set to /dev/null).

When you re-ran the script, the user was already detected, so we didn't create it again, but then the script fails again later on because clamav's home is still /dev/null and I can't read the proxy settings from there or add teh required alias to .bashrc file.

So, using the script to remove the instance and user should have worked:
Code:
./configure-clamd.sh -r
Or as you say, delete the user and try again:
Code:
userdel -r clamav
Also, had you created a new user, it would have worked, or used your existing "scott" user.

Hope that helps :-)

-c
Reply With Quote
  #15  
Old 14th May 2011, 03:52 PM
nomisunrider Offline
Registered User
 
Join Date: Oct 2006
Age: 34
Posts: 40
windows_7firefox
Re: Script for configuring ClamAV server on Fedora

Just wanted to say thanks! This was way easier to setup.

Reply With Quote
Reply

Tags
clamav, configure, script, server

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 errors configuring DNS server on Fedora 8 flillo Servers & Networking 13 24th October 2008 07:18 PM
F7 Sendmail Server & Clamav Church13 Servers & Networking 4 19th September 2007 04:25 PM
Problems configuring Samba server on Fedora 5 ishaypeled Servers & Networking 8 5th May 2006 10:30 AM
ClamAV Server/Client galeron Security and Privacy 1 25th November 2005 04:46 AM


Current GMT-time: 12:33 (Saturday, 18-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat