Skip to content

Commit

Permalink
add function for correct key installations
Browse files Browse the repository at this point in the history
  • Loading branch information
enoch85 authored Oct 3, 2024
1 parent 0ff6cd3 commit a4078e8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,40 @@ export PHP_POOL_DIR=/etc/php/"$PHPVER"/fpm/pool.d
print_text_in_color "$IGreen" PHPVER="$PHPVER"
}

add_trusted_key_and_repo() {
# EXAMPLE: add_trusted_key_and_repo "jcameron-key.asc" \
# "https://download.webmin.com" \
# "https://download.webmin.com/download/repository" \
# "sarge contrib" \
# "webmin-test.list"

# $1 = whatever.asc
# $2 = Key URL e.g. https://download.webmin.com
# $3 = Deb URL e.g. https://download.webmin.com/download/repository
# $4 = "$CODENAME $CODENAME main" (e.g. jammy jammy main)
# $5 = debpackage-name.list

# This function is only supported in the currently supported release
check_distro_version

# Do the magic
if version 22.04 "$DISTRO" 24.04.10
then
# New recommended way not using apt-key
print_text_in_color "$ICyan" "Adding trusted key in /etc/apt/keyrings/$1..."
curl -sL "$2"/"$1" | tee -a /etc/apt/keyrings/"$1"
echo "deb [signed-by=/etc/apt/keyrings/$1] $3 $4" > "/etc/apt/sources.list.d/$5"
apt-get update -q4 & spinner_loading
elif version 20.04 "$DISTRO" 20.04.10
then
# Legacy way with apt-key
print_text_in_color "$ICyan" "Adding trusted key with apt-key..."
curl -sL "$2"/"$1" | apt-key add -
echo "deb $3 $4" > "/etc/apt/sources.list.d/$5"
apt-get update -q4 & spinner_loading
fi
}

## bash colors
# Reset
Color_Off='\e[0m' # Text Reset
Expand Down

0 comments on commit a4078e8

Please sign in to comment.