mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-09 02:32:46 +01:00
Update Kafka self reset & add initial Kafka wrapper scripts to build out
Signed-off-by: reyesj2 <94730068+reyesj2@users.noreply.github.com>
This commit is contained in:
47
salt/kafka/tools/sbin/so-kafka-cli
Normal file
47
salt/kafka/tools/sbin/so-kafka-cli
Normal file
@@ -0,0 +1,47 @@
|
||||
#! /bin/bash
|
||||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||
# Elastic License 2.0.
|
||||
|
||||
if [ -z "$NOROOT" ]; then
|
||||
# Check for prerequisites
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run using sudo!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
function usage() {
|
||||
echo -e "\nUsage: $0 <script> [options]"
|
||||
echo ""
|
||||
echo "Available scripts:"
|
||||
show_available_kafka_cli_tools
|
||||
}
|
||||
|
||||
function show_available_kafka_cli_tools(){
|
||||
docker exec so-kafka ls /opt/kafka/bin | grep kafka
|
||||
}
|
||||
|
||||
if [ -z $1 ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
available_tools=$(show_available_kafka_cli_tools)
|
||||
script_exists=false
|
||||
|
||||
for script in $available_tools; do
|
||||
if [ "$script" == "$1" ]; then
|
||||
script_exists=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$script_exists" == true ]; then
|
||||
docker exec so-kafka /opt/kafka/bin/$1 "${@:2}"
|
||||
else
|
||||
echo -e "\nInvalid script: $1"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user