Graylog/install-Gaylog-v4.3.sh

94 lines
3.9 KiB
Bash

#!/bin/bash
echo "[+] Verification des droits d acces a ROOT"
if [ "$EUID" -ne 0 ];then
echo "Veuillez executer ce script en tant que ROOT"
exit 1
fi
echo "[+] Regler le redemarrage sur automatique pour eviter les pop ups de redemarrage"
sudo sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf
echo "[+] Verification des mises a jour"
apt-get update
apt-get full-upgrade -y
echo "[+] Definition du nombre maximum de fichiers pour opensearch"
sysctl -w vm.max_map_count=262144
echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
echo "[+] Installation des depenbdancies"
apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common -y
#apt-get install openjdk-17-jre-headless -y
apt-get install apt-transport-https uuid-runtime pwgen net-tools gnupg curl wget dirmngr -y
echo "[+] Installation de MongoDB"
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
wget http://ftp.fr.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_amd64.deb
dpkg -i ./libssl1.1_1.1.1w-0+deb11u1_amd64.deb
apt-get update
apt-get install -y mongodb-org
echo "[+] Demarrer de Mongod"
systemctl daemon-reload
systemctl enable mongod
systemctl restart mongod
echo "[+] Installation de Elasticsearch"
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
echo "deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list
apt update
apt -y install elasticsearch-oss
echo "[+] Sauvegarde d Elasticsearch et creation d un nouvel Elasticsearch pour Graylog"
cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.bak
tee -a /etc/elasticsearch/elasticsearch.yml > /dev/null << EOT
cluster.name: graylog
action.auto_create_index: true
EOT
echo "[+] Demarrer de Elasticsearch"
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl restart elasticsearch.service
echo "[+] Installion Graylog"
wget https://packages.graylog2.org/repo/packages/graylog-4.3-repository_latest.deb
dpkg -i graylog-4.3-repository_latest.deb
apt update
apt -y install graylog-server graylog-integrations-plugins
echo "[+] Configuration"
cp /etc/graylog/server/server.conf /etc/graylog/server/server.conf.bak
#Generate Password Secret and save it to conf file
password_secret=$(pwgen -N 1 -s 96)
#Generate initial SHA-256 Hash of the root password and save it to conf file
echo -n "Enter Password: "
read password
message=$(echo -n "$password" | sha256sum | awk '{ print $1 }')
sed -i "s/password_secret =/password_secret =$password_secret/g" /etc/graylog/server/server.conf
sed -i "s/root_password_sha2 =/root_password_sha2 =$message/g" /etc/graylog/server/server.conf
sed -i "s/#http_bind_address = 127.0.0.1:9000/http_bind_address = 0.0.0.0:9000/g" /etc/graylog/server/server.conf
echo "[+] Demarrer de Graylog"
systemctl daemon-reload
systemctl enable graylog-server.service
systemctl restart graylog-server.service
echo "#######################################################################################"
echo "## ##"
echo "## Definissez les options de memoire de la JVM pour votre serveur comme suit ##"
echo "## ##"
echo "## /etc/graylog/server/server.conf ##"
echo "## ##"
echo "## Apres la configuration, redemarrer Elasticsearch et Graylog ##"
echo "## ##"
echo "#######################################################################################"