Skip to content

Instantly share code, notes, and snippets.

@eggbean
Last active April 25, 2024 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eggbean/aad90cf15d2e798d4efe201a18b753b8 to your computer and use it in GitHub Desktop.
Save eggbean/aad90cf15d2e798d4efe201a18b753b8 to your computer and use it in GitHub Desktop.
Script for automated installation or updating the latest version of getssl (https://github.com/srvrco/getssl) using the binary packages. For Debian and RHEL-based systems.
#!/bin/bash
error_string=("Error: This command has to be run with superuser"
"privileges (under the root user on most systems).")
if [[ $(id -u) -ne 0 ]]; then echo "${error_string[@]}" >&2; exit 1; fi
eval "$(. /etc/os-release && typeset -p ID)"
if [[ $ID =~ ^(debian|ubuntu)$ ]]; then
pkg=deb
apt-get update
apt-get install -y curl jq
nameregex='^getssl_\d[\d.]+?-\d+?_all.deb$'
elif [[ $ID =~ ^(rhel|centos|almalinux|amzn|ol|rocky)$ ]]; then
pkg=rpm
yum install -y curl jq
nameregex='^getssl-\d[\d.]+?-\d+?.noarch.rpm$'
else
echo "Unsupported OS" >&2; exit 1
fi
tag="$(curl -s https://api.github.com/repos/srvrco/getssl/releases/latest | jq -r '.tag_name')"
url="$(curl -s https://api.github.com/repos/srvrco/getssl/releases/latest | \
jq -r '.assets[] | select(.name|test($name)).browser_download_url' --arg name "${nameregex}")"
wget -q "${url}" -O /tmp/getssl.${pkg} || exit 1
if [[ $pkg == deb ]]; then
dpkg -i /tmp/getssl.${pkg}
apt-get install -f -y
else
rpm -U /tmp/getssl.${pkg}
fi
rm /tmp/getssl.${pkg}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment