I'm creating a bash script to for installing docker compose. and first i want to check first if the docker already in the sources.list so i will not append again. how can i achieve this?
            Asked
            
        
        
            Active
            
        
            Viewed 87 times
        
    1 Answers
0
            
            
        For a current Debian or Ubuntu, there should already be a directory /etc/apt/sources.list.d. So my idea would be to just create a file there, put the repo in, and check for the file existance.
Like:
apt_src_file="/etc/apt/sources.list.d/docker.list"
# File exists?
if [ -f "$apt_src_file" ]; then
    echo "already installed"
    # Quit script here. If you do not want to quit, you need an ELSE section...
    exit 0
fi
# Insert source into file
echo "deb ........." > $apt_src_file
That's way easier to handle as a fulltext-search...
PS: Please NEVER paste an image to so, when plain text will do! ALWAYS copy the code!
 
    
    
        boppy
        
- 1,753
- 12
- 10

 
    