ogclone-engine/ogclient/etc/preinit/filebeat.sh

19 lines
635 B
Bash

#!/bin/bash
F=/etc/filebeat/filebeat.yml
OGLOG_PORT=9200
if [ -f $F ]; then
PASS=$(grep "^[ ]*\(export \)\?OPTIONS=" /scripts/ogfunctions 2>&1 |sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') ## taken from a sibling script
PASS=${PASS:-"og"}
chmod 0600 $F
sed -i -e "s/__OGLOG_IP__/$oglog/g" \
-e "s/__OGLOG_PORT__/$OGLOG_PORT/g" \
-e "s/__OPENSEARCH_PASSWORD__/$PASS/g" \
$F
unset PASS
mkdir -p /var/log/filebeat
/usr/bin/filebeat -c $F --path.home /usr/share/filebeat --path.config /etc/filebeat --path.data /var/lib/filebeat --path.logs /var/log/filebeat &
fi