Ftrsec

Install Splunk – one shot

				
					#!/bin/bash

check_and_install() {
    local package=$1
    if ! command -v $package &> /dev/null; then
        echo "$package is not installed. Attempting to install..."
        sudo apt-get update
        sudo apt-get install -y $package
    else
        echo "$package is already installed."
    fi
}

check_and_install wget
check_and_install gpg
check_and_install sudo

url_download_splunk='https://download.splunk.com/products/splunk/releases/9.2.1/linux/splunk-9.2.1-78803f08aabb-linux-2.6-amd64.deb'
url_licence='https://drive.google.com/uc?export=download&id=1sOx8XE4KW81s25ITCIOtltffCctKkAia'

echo -e '\n'
read -p "First enter the decryption key for the Splunk Licence: " passphrase

echo -e '\n'
read -p "How many characters you would like the admin password to have? " pass_lenght
password=$(tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c $pass_lenght)

echo " Downloading Splunk from URL"
wget -O splunk.deb $url_download_splunk

echo " Downloading and decrypting Licence"
wget -O Splunk.Licence.gpg $url_licence
gpg --batch --yes --passphrase $passphrase --decrypt Splunk.Licence.gpg > Splunk.Licence

echo "Extracting Splunk : "
dpkg -i splunk.deb

echo "Starting splunk: "
/opt/splunk/bin/splunk start --accept-license --answer-yes --no-prompt --seed-passwd $password
/opt/splunk/bin/splunk add licenses Splunk.License -auth admin:$password
/opt/splunk/bin/splunk enable boot-start -user admin --no-prompt --accept-license
/opt/splunk/bin/splunk restart

echo "finished"
echo "Your password is : $password"
				
			

Laisser un commentaire