Install Splunk – one shot


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
        echo "$package is already installed."

check_and_install wget
check_and_install gpg
check_and_install sudo


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