Handle 'configured multiple times in /etc/apt/sources.list' Warnings in bash script

Viewed 20

I'm writing a bash script that installs the Elk stack.

Each time I run my script, I get the warning that it is

configured multiple times in /etc/apt/sources.list.d/elastic-7.x.list

I guess that whenever I run the script, it adds the elasticsearch repository to the list of sources. Is there a way to handle this in my script, so I don't get this warnings whenever I run the script on same machine?

Here's a snippet of the script:

Sudo apt-get update 
wget -qO https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

echo "deb https://artifacts.elastic.co/packages/${version[0]}.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-${version[0]}.x.list

sudo apt-get update

Sudo apt-get install elasticsearch 
0 Answers
Related