Check if /etc/apt/keyrings directory exists
if [ -d "/etc/apt/keyrings" ]
Ensure /etc/apt/keyrings directory exists
if [ -f /etc/apt/sources.list.d/hashicorp.list ]
Collaborator
@stephenlauck stephenlauck 14 hours ago
I would stick to subshells with exit code execution instead of these implicit test functions. tl;dr it's more clear to stick with running commands like this if (some command)
@jlotto8 Reply...
then
echo "/etc/apt/keyrings directory already exists."
echo "HashiCorp repository is already in the sources list."
else
echo "Creating /etc/apt/keyrings directory."
sudo mkdir -p /etc/apt/keyrings
echo "Adding HashiCorp repository to sources list."
echo "deb [signed-by=/etc/apt/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list > /dev/null
sudo apt-get update
fi
let's address this asap
Check if /etc/apt/keyrings directory exists if [ -d "/etc/apt/keyrings" ]
Ensure /etc/apt/keyrings directory exists
if [ -f /etc/apt/sources.list.d/hashicorp.list ] Collaborator @stephenlauck stephenlauck 14 hours ago I would stick to subshells with exit code execution instead of these implicit test functions. tl;dr it's more clear to stick with running commands like this if (some command)
@jlotto8 Reply... then echo "/etc/apt/keyrings directory already exists." echo "HashiCorp repository is already in the sources list." else echo "Creating /etc/apt/keyrings directory." sudo mkdir -p /etc/apt/keyrings echo "Adding HashiCorp repository to sources list." echo "deb [signed-by=/etc/apt/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \ sudo tee /etc/apt/sources.list.d/hashicorp.list > /dev/null sudo apt-get update fi