
Scan with ClamAV (extended)
Source (link to git-repo or to original if based on someone elses unmodified work):
It provides the ability to scan multiple files, a progress-dialog and a result window.
Installation:
1. Start Dollphin
2. Press "Configure and control Dolphin" > "Configure Dolphin..."
3. Go to "Services"
4. "Download New Services..."
5. Search for my scripts name
6. Press "Install"
You need to have ClamAV installed.
If you encounter any issues when using the graphical way extract the file and run "sh install.sh".
All files are installed in the users home directory (/home/[user]/.kde[4]/share/kde4/services/ServiceMenus/ClamScan/), there is no need to use su or sudo to install
Note:
The script is currently translated in English, Finnish, French, German, Indonesian, Italian, Russian, Spanish, Swedish, Turkish and Ukrainian.
If you wish another language, translate the following and leave me a message or write it in a comment:
Name[en]=Scan with ClamAV
wait="ClamAV is scanning, please wait."
not_found="ClamAV is not installed!"
scan_sentence="Scanning files: "
Translations:
English Finnish (Thanks to nikore90)French (Thanks to pbuard)GermanIndonesian (Thanks to JamurBulet)Italian (Thanks to Andrea Sciucca)Russian (Thanks to Omega9)SpanishSwedish (Thanks to Jonas Norlander)Turkish (Thanks to tanzer)Ukrainian (Thanks to Localizator (localizator@ukr.net))
2013-6-18 (2.5.7)
- fixed permissions
2012-9-16 (2.5.6)
- fix: install-script: create path2 if it doesn't exist
2012-4-21 (2.5.5)
- support for linked directories
- support for empty directories
- unnecessary logfile gets deleted after scan, only result file remains
- fixed some if-conditions
- counts directories
2012-4-19 (2.5.4)
- fixed a wrong directory test (minor bug); now [ -d ] instead of [ -f ]
- did some testing on the mountable devices .desktop file, seems to work fine now
2012-4-19 (2.5.3)
- fixed a wrong set directory (~/.kde4/...) (that was for testing, I forgot to remove it)
- added spanish
- fixed this bug: gentooforum.de/artikel/17867/2/update-script.html when running ClamScan.sh without syntax
2012-2-23 (2.5.2)
- fixed recognition of empty directories which I broke in 2.3
2012-2-23 (2.5.1)
- Indonesian translation
2012-2-4 (2.5)
- using mkdir -p instead of if-conditions
(See Changelog file)
Don't forget to vote!
Ratings & Comments
78 Comments
Please upload the source code to a git repository where it can be improved further and viewed better. I'd like to create the following issue: installation fails both in the GUI and by running "sh install.sh" in latest Debian (10) stable. No option to scan with ClamAV after running this. How can this be fixed? Running mkdir /home/username/.kde/share/apps/solid/actions didn't help.
Name[pt_br]=Escanear com o ClamAV wait="O ClamAV está escaneando, por favor, aguarde." not_found="O ClamAV não está instalado!" scan_sentence="Escaneando arquivos: "
I ported your service menu to the KDE Framework 5, with some additional modifications (more accurate progressbar, etc). Do you have the files in github so that I can fork/push my modifs there ?
Maybe you can create a new Service Menus .
Hi, I've made changes to this dolphin service menu for clamav to support kde5, clamdscan or clamscan, depending on if clamd is running. I'm going to probably create a new service menu as this one looks dead. Would you like to send me your code and maybe I could merge ours together, put it on github etc. It would be nice to make other improvements such as perform actions on files that are found to be infected.
My changes were mostly about the new kf5 .local folders and some improvements (clamscan options to avoid following symbolic links: deadly trap on playonlinux/wineprefix folders, etc.) + use of inotify to get more accurate kdialog report on the number of scanned files. I am not on my previous computer now but I would try to set a github repo asap.
I've set up a repo yesterday and imported Incarus's original code. I've got code committed on my desktop computer upstairs that I still need to push. I'll go do that shortly. https://github.com/MatTaylorSharrow/ClamAVScan-Dolphin-ServiceMenu
OK, I've pushed my changes to https://github.com/MatTaylorSharrow/ClamAVScan-Dolphin-ServiceMenu feel free to fork. If you want to add to your own repo that's fine we can merge quite easily I think.
Your modifications are mostly similar to my kf5 branch here: https://github.com/b606/kf5-clamscan. Quick look for diffs: - I did not retain "kde4-config --path services" anymore but that is a good idea since some distros/apps still use it. - I do not clamd (only occasional file scan) - The progressbar is improved with some flaws, that is why I prefer using the inotify branch. - the Cancel button is working afaik
AS it stands the script ClamScan.sh uses clamscan as the scanner. As I have clamd running I've amended the script ClamScan.sh to use clamdscan instead. Needed a bit of rework to cater for the differences in the information they write to the log files and of course clamd must be running. The time to scan has reduced quite significantly. I tested on a directory with 1210 files and 9 sub-directories with a size of 3.2G, in the directory there were 19 infected files. My machine is 10 years old with P4 and 2G of memory. Using clamscan it took on average 14 mins. Clamdscan took on average 2.5 minutes. Not quite sure what to do with it. Let me know whoever might be interested. It doesn't cater for symbolic links. So really this is just a heads up. Alex
The thought behind using clamscan instead of clamdscan is that not everybody is running or using clamdscan. Not sure if at the mean time something changed about that, but it was at least not easy back in that time to set up clamdscan, at least clamscan was running out of the box. A possible fix for this would be to let the script check if clamdscan is running and if yes to prefer that one.
the current command to run clamscan in this script is: nohup clamscan -r --log="$spath"/ServiceMenus/ClamScan/logs/ClamScan_result_$date.log --stdout $real_files > "$spath"/ServiceMenus/ClamScan/logs/ClamScan_$date.log 2>&1 & we could swap it to something like if [ "$(pidof clamdscan)" ] then nohup clamdscan [...] else nohup clamscan [...] fi not sure if that is working.
Firstly can I say this is a great tool and note that Incarus has "retired" as maintainer. However, I've noticed that the progress bar in kdialog doesn't behave correctly. I believe this patch resolves the issue - --- ClamScan.sh.clamscan 2013-12-04 16:28:42.137603031 +0000 +++ ClamScan.sh 2013-12-05 10:40:06.303412347 +0000 @@ -8,7 +8,7 @@ files_old=$* IFS="," #new separator instead of spaces files=${files_old//\ \//,\/} #from " /" to ",/" -version="2.5.5" +version="2.5.8" title="ClamScan $version" date="$(date +"%H-%M-%S_%d-%m-%Y")" path="$(kde4-config --path services)" @@ -85,7 +85,7 @@ current_lines="0" progress=$(kdialog --title "$title" --progressbar "$wait -$scan_sentence $complete_amount ($complete_amount_dir directories)") +$scan_sentence $complete_amount ($complete_amount_dir directories)" $complete_amount) #qdbus $progress org.kde.kdialog.ProgressDialog.showCancelButton true else
I've manually applied the patch and still the progress bar does not update at all. Can you help me, please?
So let's see what the problem is here. The script actually checks the amount of lines in the file "$spath"/ServiceMenus/ClamScan/logs/ClamScan_$date.log each scanned file creates exactly one new line in that file, so if the amount of lines in the file == amount of all selected files the progressbar should be 100% (or x of x files). Does the mentioned file exist on your computer (is it creating while scanning)?
Yes, it is created and the files are added to it (it is automatically removed when I close the popup which contains the scan results).
I found there was a significant overhead in using clamscan for scanning small numbers of files. On my system it takes about 7.318 secs to load the dictionary and scan the smallest file in a directory. Whereas if I scan all 11 files in the directory clamscan takes 7.785 secs so really it takes only 0.467 secs to scan the 11 files. How this may be represented in the progress bar is that it displays the bar waits 7.318 secs at 0% then progresses to 100% in the remaining 0.467 secs them closes. Is this what you see? I think this was one of the reasons I swapped over to using clamdscan. In this scenario the progress bar might not register anything for the first 7 secs and then
This is actually a wanted behaviour. The progressbar is set to for example 1300, if you scan 1300 files. A small file will also count as much as a big file for the progressbar. It would be possibly to change that behavior but it would increase the amount of code. For example you could check how big the single files are (in order of the scanned files) and give the single lines a relative count (the script checks the lines of the log file: 1 more line in the log file is +1 for the progressbar until amount of lines = amount of selected files = length of the progressbar.
My problem is that I don't see the progress bar at all even if I scan more files. Xwang
The problem is that I can't fix this right now as I don't have access to a linux machine.
Incarus I understand that this is wanted behaviour and the code should be kept easily maintainable. All I was pointing out was that there is an overhead that might suggest the progress bar is not working as designed. So waiting for a reply from Xwang1976 to see if what they see can be explained by the above description. Alex
He could also do some testing out of the box if --progressbar is even working for him: http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs#Progress_Dialogs Might be a problem with DBus.
A small thing, but the ClamScan.sh file still includes the line 'version=2.5.5', which is confusing for version 2.5.7, as the KDialog box title bar includes the version number It also doesn't display the full result of the scan, just 'Result' with a dotted line underneath. The log for the day, and the individual scan logs have the full details though.
Thanks for your Feedback. I hope that I can fix this bugs in the next days but I can not longer maintain the script due to a couple of reasons. Feel free to fork this project and to maintain your own script, I also changed the license to CC BY (now without SA).
Do I miss something!? xD