Author: timopollmeier
Date: 2016-10-13 16:40:24 +0200 (Thu, 13 Oct 2016)
New Revision: 26402

Modified:
   trunk/openvas-scanner/ChangeLog
   trunk/openvas-scanner/tools/greenbone-nvt-sync.in
Log:
        * tools/greenbone-nvt-sync.in (do_wget_community_feed): Log error and
        exit on failure.
        (do_curl_community_feed): Add missing definition of TMP_NVT.  Log error
        and exit on failure.

Modified: trunk/openvas-scanner/ChangeLog
===================================================================
--- trunk/openvas-scanner/ChangeLog     2016-10-13 13:29:25 UTC (rev 26401)
+++ trunk/openvas-scanner/ChangeLog     2016-10-13 14:40:24 UTC (rev 26402)
@@ -1,3 +1,10 @@
+2016-10-13  Timo Pollmeier <timo.pollme...@greenbone.net>
+
+       * tools/greenbone-nvt-sync.in (do_wget_community_feed): Log error and
+       exit on failure.
+       (do_curl_community_feed): Add missing definition of TMP_NVT.  Log error
+       and exit on failure.
+
 2016-10-11  Hani Benhabiles  <hani.benhabi...@greenbone.net>
 
        * src/pluginscheduler.c (plugin_next_unrun_dependency): Add parameter to

Modified: trunk/openvas-scanner/tools/greenbone-nvt-sync.in
===================================================================
--- trunk/openvas-scanner/tools/greenbone-nvt-sync.in   2016-10-13 13:29:25 UTC 
(rev 26401)
+++ trunk/openvas-scanner/tools/greenbone-nvt-sync.in   2016-10-13 14:40:24 UTC 
(rev 26402)
@@ -370,23 +370,63 @@
 
   log_info "Configured NVT http feed: $COMMUNITY_NVT_HTTP_FEED"
   log_info "Downloading to: $TMP_NVT"
-  mkdir -p "$NVT_DIR" \
-    && wget "$COMMUNITY_NVT_HTTP_FEED" -O $TMP_NVT \
-    && cd "$NVT_DIR" \
-    && tar xvjf $TMP_NVT \
-    && rm -f $TMP_NVT \
-    && log_info "Download complete"
+  mkdir -p "$NVT_DIR"
+
+  wget "$COMMUNITY_NVT_HTTP_FEED" -O $TMP_NVT
+
+  if [ $? -ne 0 ]
+  then
+    rm -f $TMP_NVT
+    log_err "wget failed"
+    exit 1
+  else
+    log_info "Download complete"
+  fi
+
+  cd "$NVT_DIR" \
+    && tar xvjf $TMP_NVT
+
+  if [ $? -ne 0 ]
+  then
+    rm -f $TMP_NVT
+    log_err "tar extraction failed."
+    exit 1
+  else
+    rm -f $TMP_NVT
+    log_info "NVTs extracted successfully"
+  fi
 }
 
 do_curl_community_feed () {
+  TMP_NVT="$SYNC_TMP_DIR/openvas-feed-`date +%F`-$$.tar.bz2"
+
   log_info "Configured NVT http feed: $COMMUNITY_NVT_HTTP_FEED"
   log_info "Downloading to: $TMP_NVT"
-  mkdir -p "$NVT_DIR" \
-    && curl "$COMMUNITY_NVT_HTTP_FEED" -o $TMP_NVT \
-    && cd "$NVT_DIR" \
-    && tar xvjf $TMP_NVT \
-    && rm -f $TMP_NVT \
-    && log_info "Download complete"
+  mkdir -p "$NVT_DIR"
+
+  curl "$COMMUNITY_NVT_HTTP_FEED" -o $TMP_NVT
+
+  if [ $? -ne 0 ]
+  then
+    rm -f $TMP_NVT
+    log_err "curl failed"
+    exit 1
+  else
+    log_info "Download complete"
+  fi
+
+  cd "$NVT_DIR" \
+    && tar xvjf $TMP_NVT
+
+  if [ $? -ne 0 ]
+  then
+    rm -f $TMP_NVT
+    log_err "tar extraction failed."
+    exit 1
+  else
+    rm -f $TMP_NVT
+    log_info "NVTs extracted successfully"
+  fi
 }
 
 do_rsync_community_feed () {

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to