Ok, I try to make an automated script for my lets encrypt on namecheap. I’M NO EXPERT IN BASH/LINUX STUFF, BUT I’M A QUICK STUDY
I want to automate the certificate creation as much as possible, so that with one line I can create & validate an external domain.
So far, I’ve made a script that I called in PHP that changes my TXT for a domain under my guard on a distant server (shared hosting with reseller account). For exemple, if I ask my server to go to http://exemple.com/?challengestr=ABC&domain=domain.com, it will change the _acme… TXT domain for domain.com to ABC.
So when I call the next line, the domain and validation are pushed by curl to the server, the validation key is added to the server, and the ownership is validated.
OK, but this has nothing todo with your initial problem, where environment variables did not get expanded correctly. Nobody could learn anything from this thread.
By the way: as long as your whole setup is not finished, I would recommend using the staging environment for your tests, not the production environment.
It might also be good to put some kind of authentication in there, so that other people who some how learn about this service can't use your API to get certificates for your domains!