Skip to content

Instantly share code, notes, and snippets.

@taylorwalton
Last active October 20, 2023 12:17
Show Gist options
  • Save taylorwalton/a23f7e99c49e42bc524d61551d2045ba to your computer and use it in GitHub Desktop.
Save taylorwalton/a23f7e99c49e42bc524d61551d2045ba to your computer and use it in GitHub Desktop.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PACKETBEAT_YAML="https://raw.githubusercontent.com/socfortress/Wazuh-Rules/main/Packetbeat/packetbeat.yml"
logger() {
now=$(date +'%m/%d/%Y %H:%M:%S')
case $1 in
"-e")
mtype="ERROR:"
message="$2"
;;
"-w")
mtype="WARNING:"
message="$2"
;;
*)
mtype="INFO:"
message="$1"
;;
esac
echo $now $mtype $message
}
if [ -n "$(command -v yum)" ]; then
sys_type="yum"
sep="-"
elif [ -n "$(command -v zypper)" ]; then
sys_type="zypper"
sep="-"
elif [ -n "$(command -v apt-get)" ]; then
sys_type="apt-get"
sep="="
fi
DIR="/etc/packetbeat"
if [ -d "$DIR" ]; then
logger "Packetbeat found. Not Installing"
exit 0
else
logger "Installing Packetbeat"
if [ ${sys_type} == "yum" ]; then
eval "curl -L -O https://artifacts.elastic.co/downloads/beats/packetbeat/packetbeat-7.16.3-x86_64.rpm ${debug}"
eval "rpm -vi packetbeat-7.16.3-x86_64.rpm ${debug}"
eval "wget ${PACKETBEAT_YAML} -O /etc/packetbeat/packetbeat.yml ${debug}"
elif [ ${sys_type} == "apt-get" ]; then
eval "curl -L -O https://artifacts.elastic.co/downloads/beats/packetbeat/packetbeat-7.16.3-amd64.deb ${debug}"
eval "dpkg -i packetbeat-7.16.3-amd64.deb ${debug}"
eval "wget ${PACKETBEAT_YAML} -O /etc/packetbeat/packetbeat.yml ${debug}"
fi
fi
service packetbeat restart
logger "Need assistance? Shoot us an email at [email protected]!"
@iamenderst
Copy link

iamenderst commented Nov 28, 2022

At the bottom, for me I changed it to:

fi
systemctl enable packetbeat --now
service packetbeat restart

Otherwise, it will not survive a reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment