j-c-m / ubnt-letsencrypt

Let's Encrypt setup instructions for Ubiquiti EdgeRouter
472 stars 68 forks source link

Convert script to use acme.sh hooks/commands and built-in --cron #22

Open dotsam opened 6 years ago

dotsam commented 6 years ago

This PR largely just chops up the existing script into multiple files that can be used as hook/commands by acme.sh. The files are as follows:

  1. A setup.sh script that does the initial issuing of the certificate. It also now spits out the configuration commands at the end. Once used, this file isn't needed anymore.
  2. A pre-hook.sh script that stops the built-in GUI, sets up the temporary lighttpd instance, and firewall rules
  3. A post-hook.sh script which puts things back the way they were
  4. A reloadcmd.sh which combines the cert and key and copies the CA cert

With these in place, it's possible to use acme.sh's built-in --cron option which doesn't do anything if the certificate doesn't need to be renewed, thus preventing unneeded restarts of the GUI/web server.

I've tried to avoid hard-coding paths as much as possible in case anyone wanted to move the scripts to a different location.