Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -x
- set -e
- # Make sure only root can run our script
- if [ "$(id -u)" != "0" ]; then
- echo "This script must be run as root" 1>&2
- exit 1
- fi
- # Check if OS is CentOS
- if [ -f /etc/debian_version ]; then
- echo "[`date`] ========= Installing updates ========="
- apt-get update -y && apt-get upgrade -y
- apt-get install wget curl vim git net-tools -y
- else
- echo "Please use CentOS to run this software :)"
- fi
- ################################## Install/Setup Filebeat ##################################
- # Add APT key
- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- # Add repot
- sudo apt-get install apt-transport-https
- echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
- sudo apt-get update -y
- sudo apt-get install filebeat -y
- # Get the domain
- read -p "Enter domain name: " -e domainName
- # Create config directory for filebeat
- mkdir /etc/filebeat/conf.d/
- cp /etc/filebeat/filebeat.yml /etc/filebeat/filebeat.yml.bak
- cat > /etc/filebeat/filebeat.yml << EOF
- filebeat:
- registry_file: /var/lib/filebeat/registry
- config_dir: /etc/filebeat/conf.d
- output.logstash:
- hosts: ["$domainName:5044"]
- EOF
- # Logging script
- cat > /etc/filebeat/conf.d/logging.yml << EOF
- filebeat.prospectors:
- - input_type: log
- paths:
- - /var/log/*
- document_type: syslog
- EOF
- # Add filebeat to boot
- update-rc.d filebeat defaults 95 10
- service filebeat restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement