Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kousu/dehydrated-hooks
hook.d support for dehydrated.io
https://github.com/kousu/dehydrated-hooks
Last synced: 9 days ago
JSON representation
hook.d support for dehydrated.io
- Host: GitHub
- URL: https://github.com/kousu/dehydrated-hooks
- Owner: kousu
- License: mit
- Created: 2021-04-11T00:19:20.000Z (almost 4 years ago)
- Default Branch: trunk
- Last Pushed: 2021-04-20T07:22:53.000Z (almost 4 years ago)
- Last Synced: 2025-01-06T17:34:32.965Z (27 days ago)
- Language: Shell
- Size: 22.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hooks.d plugin for dehydrated.io
https://dehydrated.io is a great simple [ACME client](https://letsencrypt.org/docs/client-options/).
It has a `conf.d` directory so that packages can coordinate installing plugins,
but [doesn't want to provide a similar `hooks.d`](https://github.com/dehydrated-io/dehydrated/issues/270) directory
so that they can coordinate installing hooks, which are scripts that react to actions taken by `dehydrated`.This provides that feature 🌉.
## Installation
### From source
```
git clone https://github.com/kousu/dehydrated-hooks
cd dehydrated-hooks
install -o root -g root conf.d/hooks.sh /etc/dehydrated/conf.d # or wherever your dehydrated's ${CONF_D} is pointed.
install -o root -g root hooks.sh /var/lib/dehydrated/hooks/ # or wherever your dehydrated's ${BASEDIR}/hooks/ is.
```### From package
#### Debian/Ubuntu
Pick out the appropriate .deb file for your version from https://github.com/kousu/dehydrated-hooks/releases/ and install it by:
```
wget https://github.com/kousu/dehydrated-hooks/releases/download/1.0.0/dehydrated-hooks_1.0.0-0ubuntu1.focal_all.deb
apt-get install -y ./dehydrated-hooks_1.0.0-0ubuntu1.bionic_all.deb
```## Usage
There are three hooks `dehydrated` will run, and each has a separate directory of hooks:
* `deploy-challenge` in `"${BASEDIR}"/hooks/deploy-challenge.d/`, run after receiving the challenge from the CA with arguments `altname token-filename token-content`.
* `clean-challenge` in `"${BASEDIR}"/hooks/clean-challenge.d/`, run (???) with arguments `"" token-filename token-content`
* `deploy-cert`, in `"${BASEDIR}"/hooks/deploy-cert.d/`, run after receiving a newly signed cert from the CA, with arguments `domain path/to/privkey.pem path/to/cert.pem path/to/fullchain.pem`Put scripts or other programs in these directories as necessary, make sure to `chmod +x` them, and they will be invoked the next time you run `dehydrated -c`.
You can control the order the hooks run in by naming them -- so a hook that should run before everything should start '00-',
and one that should run after everything should be 'zz-'. But ideally you won't need to use that very much.### Testing
To test your hooks non-destructively...
TODO
## Examples
Once installed, here are some things you can do with this:
### Keeping certs under `/etc/ssl/`
```
#!/bin/sh
# /var/lib/dehydrated/hooks/deploy-cert.d/00-install
# install certificates from dehydrated into /etc/
# certs form part of system config, so they belong under /etc, though the *originals* live under /var/
# Another solution would be to set CERTDIR=/etc/dehydrated/certs/ but that's sort of weird too.domain="$1"
privkey="$2"
cert="$3"
fullchain="$4"cp "$fullchain" /etc/ssl/certs/"$domain".pem
cp "$privkey" /etc/ssl/private/"$domain".key
``````
#!/bin/sh
# /var/lib/dehydrated/hooks/deploy-cert.d/01-etckeeper
# meant to be used with 00-install
domain="$1"
etckeeper commit "Renew cert for $domain."
```### Make all your daemons pick up the new certificates
```
#!/bin/sh
# /var/lib/dehydrated/hooks/deploy-cert.d/nginx
systemctl reload nginx
``````
#!/bin/sh
# /var/lib/dehydrated/hooks/deploy-cert.d/prosody
prosodyctl reload
``````
#!/bin/sh
# /var/lib/dehydrated/hooks/deploy-cert.d/rsyslogd
systemctl reload rsyslogd
```You could put all of these into one line, but then your services become interdependent and that makes them more fragile: if you to replace nginx with apache you need to remember to take it out of your hook script; this way, you just `rm /var/lib/dehydrated/hooks/deploy-cert.d/nginx` and replace it with a `/var/lib/dehydrated/hooks/deploy-cert.d/apache`.
### Use a specific DNS-01 for different subdomains
TODO