Created
March 20, 2021 15:01
-
-
Save rcmelendez/da03af28aa648c87ad4025f59b06c944 to your computer and use it in GitHub Desktop.
Bash shell script that runs Zeek IDS automatically on macOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Bash shell script that starts the Zeek process if it's not running. | |
# | |
# Add this script to the root crontab, e.g.: | |
#*/5 * * * * /Users/roberto/zeek.sh > /tmp/zeek.log 2>&1 | |
# | |
# | |
# Version: 1.0.0 | |
# Author: Roberto Meléndez [Cambridge, USA] | |
# Medium: https://medium.com/@rcmelendez/ | |
# Released: March 19, 2021 | |
set -euo pipefail | |
# Get the process status and pid | |
zeek_status=$(/usr/local/bin/zeekctl status | awk 'END {print $4}' || true) | |
zeek_pid=$(/usr/local/bin/zeekctl status | awk 'END {print $5}' || true) | |
# Run the deploy command if Zeek is not running | |
# BPF device permissions have to be changed manually every time our Mac reboots :( | |
if [[ "${zeek_status}" != "running" ]]; then | |
chgrp admin /dev/bpf* | |
chmod g+r /dev/bpf* | |
/usr/local/bin/zeekctl deploy | |
else | |
echo "Nothing to do, Zeek is running with pid ${zeek_pid}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment