aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-08-17 15:23:48 +0000
committerGitHub2020-08-17 15:23:48 +0000
commit44b03e88339ce5c8e01d832ed2696ec4071c7401 (patch)
treee73f0cd03b5f5d7d7a62d31bc0a8f2c24a1cce92
parentfe511f33c451a4c1c85950d0619b927747757d4e (diff)
parentca1228c1f38a2b81527d4401e1a6dc6f09c7a2ba (diff)
Merge pull request #3 from TheLillo/develop
Create script to feed Caronte with fresh pcap
-rwxr-xr-xscripts/feedCaronte.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/feedCaronte.sh b/scripts/feedCaronte.sh
new file mode 100755
index 0000000..daf8577
--- /dev/null
+++ b/scripts/feedCaronte.sh
@@ -0,0 +1,52 @@
+#!/bin/bash -
+#===============================================================================
+#
+# FILE: feedCaronte.sh
+#
+# USAGE: ./feedCaronte.sh PCAP_DIR_PATH
+#
+# DESCRIPTION:
+#
+# OPTIONS: ---
+# REQUIREMENTS: inotify-tools, curl
+# BUGS: ---
+# NOTES: test in Debian Buster
+# AUTHOR: Andrea Giovine (AG),
+# ORGANIZATION:
+# CREATED: 17/08/2020 16:36:57
+# REVISION: ---
+#===============================================================================
+
+set -o nounset # Treat unset variables as an error
+
+CHECK_INOTIFY=$(dpkg-query -W -f='${status}' 'inotify-tools')
+
+if [[ "$CHECK_INOTIFY" != 'install ok installed' ]]; then
+ echo "Install inotify-tools"
+ exit 1
+fi
+
+CHECK_CURL=$(dpkg-query -W -f='${Status}' 'curl')
+
+if [[ "$CHECK_CURL" != 'install ok installed' ]]; then
+ echo "Install curl"
+ exit 1
+fi
+
+if [[ "$#" -ne 1 ]]; then
+ echo "Need 1 arg"
+ exit 2
+fi
+
+PCAP_DIR="$1"
+
+if [[ -z "$PCAP_DIR" ]]; then
+ echo "Need path to dir where are store pcaps"
+ exit 2
+fi
+
+inotifywait -m "$PCAP_DIR" -e create -e moved_to |
+ while read dir action file; do
+ echo "The file $file appeared in directory $dir via $action"
+ curl -F "file=@$file" "http://localhost:3333/api/pcap/upload"
+ done