#!/bin/bash

SUPPORT="https://installers.seedbox.vip/oci/support"

curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add - || exit 1
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" \
    | tee /etc/apt/sources.list.d/elastic-7.x.list
apt update || exit 1
apt -y install filebeat || exit 1

filebeat modules enable system
filebeat modules enable apache
filebeat modules enable nginx

# Modify /etc/filebeat/filebeat.yml
for _f in filebeat.yml ca.crt logs.crt logs.key ; do
    wget -4 -t 15 -O /etc/filebeat/${_f} "${SUPPORT}/filebeat/${_f}" || exit 1
done

systemctl enable filebeat
systemctl start filebeat
