Last active
April 2, 2018 17:19
-
-
Save literalplus/ec3d091fc718945ee54bfdf7d834d090 to your computer and use it in GitHub Desktop.
Bash script to bulk-check if ACME HTTP webroot responses are working. Requires a file with the content "HENLO" to be present at /.well-known/acme-challenge/test.txt
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 | |
# Checks whether given domain has a file at .well-known/acme-challenge/test.txt | |
# with content "HENLO", for HTTP and HTTPS. | |
# Pass -q to hide the curl progress bar. | |
QUIET="" | |
RED="\e[31m" | |
GREEN="\e[92m" | |
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then | |
echo "$0 [-q] DOMAIN" | |
exit 1 | |
elif [ "$1" == "-q" ]; then | |
if [ "$#" -lt 2 ]; then | |
echo "$0 [-q] DOMAIN" | |
exit 1 | |
fi | |
DOMAIN="$2" | |
QUIET="-s" | |
else | |
DOMAIN="$1" | |
fi | |
CURL="$(which curl)" | |
PATH=".well-known/acme-challenge/test.txt" | |
#echo " Testing for HTTP..." | |
HTTP_RES="$($CURL $QUIET -L http://$DOMAIN/$PATH)" | |
if [ "$HTTP_RES" != "HENLO" ]; then | |
echo -e "$RED ... $DOMAIN HTTP failed! Result: $HTTP_RES" | |
exit 2 | |
else | |
echo -e "$GREEN ... $DOMAIN HTTP is ok." | |
fi | |
#echo " Testing for HTTPS..." | |
HTTPS_RES="$($CURL $QUIET -L https://$DOMAIN/$PATH)" | |
if [ "$HTTPS_RES" != "HENLO" ]; then | |
echo -e "$RED ... $DOMAIN HTTPS failed! Result: $HTTPS_RES" | |
exit 2 | |
else | |
echo -e "$GREEN ... $DOMAIN HTTPS is ok." | |
fi |
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 | |
# Runs acme-test.sh for each domain in a Let's Encrypt renewal file. | |
# These are located at /etc/letsencrypt/renewal/example.com.conf | |
RED="\e[31m" | |
GREEN="\e[92m" | |
if [ "$#" -ne 1 ]; then | |
echo "$0 RENEWAL_CONFIG_FILE" | |
exit 1 | |
fi | |
sed -n '/\[\[webroot_map\]\]/,$p' $1 | \ | |
grep -P -o '(.+)(?= = \/var\/www\/letsencrypt)' | \ | |
xargs -L 1 ./acme-test.sh -q | |
TEST_RESULT="$?" | |
if [ "$TEST_RESULT" -ne 0 ]; then | |
echo -e "$RED[ERROR] One or more tests failed (code $TEST_RESULT). Check the output." | |
exit 123 | |
else | |
echo -e "$GREEN[SUCCESS] All tests passed." | |
exit 0 | |
fi |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2004 Sam Hocevar <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment