Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i check if gnupg is installed on ubuntu and run a shell script to install it if it is not installed?

#! /bin/bash


if which gnupg >/dev/null; then 
    echo "Installed"
else
    echo "Not installed" #If not installed

echo "Installing..."
sudo apt-get install gnupg #installation

fi

Do you have any idea? when i run this, it shows that is not installed but it tries to update it. And as a result it says : gnupg is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 46 not upgraded.

like image 452
Alex Andreadis Avatar asked Oct 15 '25 16:10

Alex Andreadis


1 Answers

You have to look for gpg (the actual executable name), not gnupg (the package name). This should solve the problem.

if which gpg >/dev/null; then 
    echo "Installed"
# ...
fi
like image 184
Ale Avatar answered Oct 18 '25 11:10

Ale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!