Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -x
  4. set -e
  5.  
  6. # Make sure only root can run our script
  7. if [ "$(id -u)" != "0" ]; then
  8.    echo "This script must be run as root" 1>&2
  9.    exit 1
  10. fi
  11.  
  12. # Check if OS is CentOS
  13. if [  -f /etc/debian_version ]; then
  14.   echo "[`date`] ========= Installing updates ========="
  15.   apt-get update -y && apt-get upgrade -y
  16.   apt-get install wget curl vim git net-tools -y
  17. else
  18.   echo "Please use CentOS to run this software :)"
  19. fi
  20.  
  21. ################################## Install/Setup Filebeat ##################################
  22. # Add APT key
  23. wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
  24.  
  25. # Add repot
  26. sudo apt-get install apt-transport-https
  27. echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
  28.  
  29. sudo apt-get update -y
  30. sudo apt-get install filebeat -y
  31.  
  32. # Get the domain
  33. read -p "Enter domain name: " -e domainName
  34.  
  35. # Create config directory for filebeat
  36. mkdir /etc/filebeat/conf.d/
  37. cp /etc/filebeat/filebeat.yml /etc/filebeat/filebeat.yml.bak
  38. cat > /etc/filebeat/filebeat.yml << EOF
  39. filebeat:
  40.   registry_file: /var/lib/filebeat/registry
  41.   config_dir: /etc/filebeat/conf.d
  42.  
  43. output.logstash:
  44.   hosts: ["$domainName:5044"]
  45. EOF
  46.  
  47. # Logging script
  48. cat > /etc/filebeat/conf.d/logging.yml << EOF
  49. filebeat.prospectors:
  50.   - input_type: log
  51.     paths:
  52.       - /var/log/*
  53.     document_type: syslog
  54. EOF
  55.  
  56. # Add filebeat to boot
  57. update-rc.d filebeat defaults 95 10
  58. service filebeat restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement