Salida de comillas dobles y variable.

Salida de comillas dobles y variable.

Estoy escribiendo un script para automatizar Let's Encrypt en PowerDNS (este es un script de bash shell simple para ejecutar en Debian)

Certbot ejecuta y llama al script, alimentándole la variable: $CERTBOT_VALIDATION

ya leí un hiloaquílo que muestra la necesidad de '"content"'– observe las comillas simples  'y las comillas dobles  ". (He probado esto en una iteración diferente del código sin éxito) Estoy luchando para generar la variable expandida entre comillas, aquí hay una forma en que lo intenté:

pdnsutil add-record Example.com _acme-challenge txt 120 "\"%s\""  "$CERTBOT_VALIDATION"

Sin embargo, para generar eso desde bash, debo agregar un \antes del archivo ".

Quiero que el comando de salida sea el siguiente:

 pdnsutil add-record Example.com _acme-challenge txt 120 "content"

¿Cuál es la mejor manera de hacer esto?

lo que sea que se esté generando actualmente tiene un error con:

Error: Parsing record content (try 'pdnsutil check-zone'): Data field in DNS should start with quote (") at position 0 of ''yXtgt_2vlnrF7j2V-eTJZuSjXbswsGN97TQ0Zp3IynM''

Respuesta1

Proporcionaré una actualización como posible respuesta para cualquiera que se encuentre con esto en el futuro.

al ejecutar el comando certbot:

certbot certonly --manual --preferred-challenges=dns --manual-auth-hook /etc/letsencrypt/customScripts/authenticator.sh -d *.example.com --dry-run

el script authenticator.sh ahora es:

#!/bin/bash
new='"'
new2=$new$CERTBOT_VALIDATION$new
pdnsutil add-record example.com _acme-challenge txt 120 $new2
echo $new2 > output.log
# Sleep to make sure the change has time to propagate over to DNS
sleep 25

esto funciona, concatenando las variables como cadenas para agregar comillas dobles. output.log muestra que la variable era

cat output.log 
"RipQQbHO5pG95nzJjouCgTXJMrGTbLKQ5XsV5Zgn7uI"

y informes de certbot:

certbot certonly --manual --preferred-challenges=dns --manual-auth-hook /etc/letsencrypt/customScripts/authenticator.sh -d *.example.com --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Output from authenticator.sh:
RipQQbHO5pG95nzJjouCgTXJMrGTbLKQ5XsV5Zgn7uI
New rrset:
_acme-challenge.example.com. IN TXT 120 "RipQQbHO5pG95nzJjouCgTXJMrGTbLKQ5XsV5Zgn7uI"

Error output from authenticator.sh:
Apr 05 10:51:41 Reading random entropy from '/dev/urandom'
Apr 05 10:51:41 gmysql Connection successful. Connected to database 'pdns' on '127.0.0.1'.
Apr 05 10:51:41 gmysql Connection successful. Connected to database 'pdns' on '127.0.0.1'.

Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - The dry run was successful.

entonces esto parece haberlo resuelto.

información relacionada