Created
December 6, 2019 19:12
-
-
Save jflemer-ndp/0426fe40d09a35b1699c14cf73ba9846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# test each redhat subscription key against a given (repo) url | |
if [ -z "$1" ]; then | |
echo "usage: $0 <url>" | |
echo "" | |
echo "example:" | |
echo " $0 'https://cdn.redhat.com/content/dist/rhel/server/7/\$releasever/\$basearch/os/repodata/repomd.xml'" | |
exit 1 | |
fi | |
url() { | |
local x="${1//\$basearch/x86_64}" | |
case "$x" in | |
*releasever*) | |
echo "${x//\$releasever/7Server}/repodata/repomd.xml" | |
echo "${x//\$releasever/7Server}" | |
echo "${x//\$releasever/7Workstation}/repodata/repomd.xml" | |
echo "${x//\$releasever/7Workstation}" | |
;; | |
*) | |
echo "$x/repodata/repomd.xml" | |
echo "$x" | |
;; | |
esac | |
} | |
for u in $(url "$1"); do | |
for i in /etc/pki/entitlement/*key.pem; do | |
id=$(basename "${i%%-key.pem}") | |
echo "==> $id $u" | |
curl --fail --cert /etc/pki/entitlement/${id}.pem --key /etc/pki/entitlement/${id}-key.pem -k $u >/dev/null 2>&1 && echo "$id $u" && exit 0 | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment