summaryrefslogtreecommitdiff
path: root/security/openvas-plugins/files/patch-openvas-nvt-sync.in
blob: 72b97b01c2bd1e1fe8a4776506be000cf7523990 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$FreeBSD$

--- openvas-nvt-sync.in.orig
+++ openvas-nvt-sync.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # OpenVAS
 # $Id$
@@ -62,16 +62,20 @@
 chk_system_tools(){
 echo "Searching for required system tools ..."
 
-RSYNC=`findcmd rsync`
-MD5SUM=`findcmd md5sum`
+RSYNC=`which rsync`
+if [ `uname -s` = "FreeBSD" ]; then
+    MD5SUM=`which gmd5sum`
+else
+    MD5SUM=`which md5sum`
+fi
 
-if [ -z "$RSYNC" ]; then
-  echo "Error: RSYNC not found";
+if [ ! -f "$RSYNC" ]; then
+  echo "Error: rsync not found in \$PATH=$PATH" 1>&2
   exit -1
 fi
 
-if [ -z "$MD5SUM" ]; then
-  echo "Error: MD5SUM not found";
+if [ ! -f "$MD5SUM" ]; then
+  echo "Error: md5 not found in \$PATH=$PATH" 1>&2
   exit -1
 fi
 }
@@ -80,15 +84,15 @@
   echo "Synchonizing NVTs via RSYNC ..."
 
   mkdir -p "$NVT_DIR"
-  eval "rsync -ltvrP \"$FEED\" \"$NVT_DIR\""
+  eval "$RSYNC -ltvrP \"$FEED\" \"$NVT_DIR\""
   if [ $? -ne 0 ] ; then
-    echo "Error: rsync failed. Your NVT collection might be broken now."
+    echo "Error: rsync failed. Your NVT collection might be broken now." 1>&2
     exit 1
   fi
-  eval "cd \"$NVT_DIR\" ; md5sum -c --status \"$NVT_DIR/md5sums\""
+  eval "cd \"$NVT_DIR\" ; $MD5SUM -c --status \"$NVT_DIR/md5sums\""
   if [ $? -ne 0 ] ; then
-    echo "Error: md5sums not correct. Your NVT collection might be broken now."
-    echo "Please try this for details: cd \"$NVT_DIR\" ; md5sum -c \"$NVT_DIR/md5sums\" | less"
+    echo "Error: md5sums not correct. Your NVT collection might be broken now." 1>&2
+    echo "Please try this for details: cd \"$NVT_DIR\" ; md5sum -c \"$NVT_DIR/md5sums\" | less" 1>&2
     exit 1
   fi