Added hook scripts
This commit is contained in:
parent
08be8b58a8
commit
b9fbafc392
3 changed files with 84 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
certbot-auto
|
||||
etc/
|
||||
#.*#
|
||||
.*~
|
||||
|
|
42
letsencrypt/lets_authenticator.sh
Executable file
42
letsencrypt/lets_authenticator.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
LOG_FILE='/tmp/lets_auth.log'
|
||||
DNS_DB_MYCNF="/usr/local/ortiche/otcerts/etc/dns_db.conf"
|
||||
|
||||
echo "Auth $CERTBOT_DOMAIN"
|
||||
|
||||
echo "" >> $LOG_FILE
|
||||
date >> $LOG_FILE
|
||||
|
||||
RECORD_NAME='_acme-challenge'
|
||||
RECORD_FQDN="$RECORD_NAME.$CERTBOT_DOMAIN"
|
||||
|
||||
DOMAIN_ID=`mysql --defaults-extra-file=$DNS_DB_MYCNF -s -N << END_QUERY
|
||||
SELECT domains.id FROM domains WHERE domains.name='$CERTBOT_DOMAIN'
|
||||
END_QUERY`
|
||||
|
||||
if [ -z "$DOMAIN_ID" ]; then
|
||||
echo "ERROR: Nameservers are not managed for domain $CERTBOT_DOMAIN" >> $LOG_FILE
|
||||
exit 255
|
||||
fi
|
||||
|
||||
echo "Selected domain_id $DOMAIN_ID" >> $LOG_FILE
|
||||
|
||||
echo "Creating $RECORD_FQDN TXT entry with value $CERTBOT_VALIDATION" >> $LOG_FILE
|
||||
|
||||
QUERY_RES=`mysql --defaults-extra-file=$DNS_DB_MYCNF -s -N << END_QUERY
|
||||
INSERT INTO records (domain_id, name, type, content, ttl, prio, label)
|
||||
VALUES ($DOMAIN_ID, '$RECORD_FQDN', 'TXT', '"$CERTBOT_VALIDATION"', 5, 60, '"$CERTBOT_VALIDATION"')
|
||||
END_QUERY`
|
||||
|
||||
# echo "Done updating" >> $LOG_FILE
|
||||
RECORD_ID=`mysql --defaults-extra-file=$DNS_DB_MYCNF -s -N << END_QUERY
|
||||
SELECT id FROM records WHERE (type='TXT' and name='$RECORD_FQDN')
|
||||
END_QUERY`
|
||||
|
||||
echo "After update $RECORD_ID ." >> $LOG_FILE
|
||||
echo "Done updating, sleeping 10 secs .. " >> $LOG_FILE
|
||||
sleep 5
|
||||
echo "Done sleeping." >> $LOG_FILE
|
||||
# dig @172.19.0.102 $RECORD_FQDN TXT +short >> $LOG_FILE
|
||||
# dig @dns.contaminati.net $RECORD_FQDN TXT +short >> $LOG_FILE
|
||||
# dig @dns.ortiche.net $RECORD_FQDN TXT +short >> $LOG_FILE
|
||||
exit 0
|
41
letsencrypt/lets_cleanup.sh
Executable file
41
letsencrypt/lets_cleanup.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
LOG_FILE='/tmp/lets_clean.log'
|
||||
DNS_DB_MYCNF="/usr/local/ortiche/otcerts/etc/dns_db.conf"
|
||||
|
||||
echo "" >> $LOG_FILE
|
||||
date >> $LOG_FILE
|
||||
|
||||
|
||||
|
||||
echo "CERTBOT_AUTH_OUTPUT = $CERTBOT_AUTH_OUTPUT" >> $LOG_FILE
|
||||
|
||||
RECORD_NAME='_acme-challenge'
|
||||
RECORD_FQDN="$RECORD_NAME.$CERTBOT_DOMAIN"
|
||||
|
||||
DOMAIN_ID=`mysql --defaults-extra-file=$DNS_DB_MYCNF -s -N << END_QUERY
|
||||
SELECT domains.id FROM domains WHERE domains.name='$CERTBOT_DOMAIN'
|
||||
END_QUERY`
|
||||
|
||||
if [ -z "$DOMAIN_ID" ]; then
|
||||
echo "ERROR: Nameservers are not managed for domain $CERTBOT_DOMAIN" >> $LOG_FILE
|
||||
exit 255
|
||||
fi
|
||||
|
||||
RECORD_ID=`mysql --defaults-extra-file=$DNS_DB_MYCNF -s -N << END_QUERY
|
||||
SELECT id FROM records WHERE (type='TXT' and name='$RECORD_FQDN')
|
||||
END_QUERY`
|
||||
|
||||
echo "Cleaning $RECORD_FQDN TXT entry, record id $RECORD_ID" >> $LOG_FILE
|
||||
|
||||
# QUERY_RES=`mysql --defaults-extra-file=$DNS_DB_MYCNF -s -N << END_QUERY
|
||||
# UPDATE records SET content='""' WHERE id=$RECORD_ID
|
||||
# END_QUERY`
|
||||
|
||||
# To complete delete
|
||||
DELETE_RES=`mysql --defaults-extra-file=$DNS_DB_MYCNF -s -N << END_QUERY
|
||||
DELETE FROM records WHERE (domain_id=$DOMAIN_ID AND name='$RECORD_FQDN')
|
||||
END_QUERY`
|
||||
|
||||
echo "Done cleaning, sleeping 5 secs .. " >> $LOG_FILE
|
||||
sleep 5
|
||||
echo "Done sleeping." >> $LOG_FILE
|
||||
exit 0
|
Loading…
Reference in a new issue