2024-10-10 08:13:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Mosquitto is running with a user that is not privileged enough to read files
|
|
|
|
# directly from the certbot dirs, so copy files to where mosquitto expects
|
|
|
|
# them.
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
le_dir="/etc/letsencrypt/live/$(hostname -f)"
|
2024-10-10 08:36:00 +00:00
|
|
|
mosquitto_dir="/etc/mosquitto"
|
2024-10-10 08:13:04 +00:00
|
|
|
|
|
|
|
le_chain="$le_dir/chain.pem"
|
|
|
|
mosquitto_chain="$mosquitto_dir/ca_certificates/chain.pem"
|
2024-10-10 08:38:45 +00:00
|
|
|
cp "$le_chain" "$mosquitto_chain"
|
|
|
|
chown mosquitto:root "$mosquitto_chain"
|
2024-10-10 08:13:04 +00:00
|
|
|
|
|
|
|
le_cert="$le_dir/cert.pem"
|
|
|
|
mosquitto_cert="$mosquitto_dir/certs/cert.pem"
|
2024-10-10 08:38:45 +00:00
|
|
|
cp "$le_cert" "$mosquitto_cert"
|
|
|
|
chown mosquitto:root "$mosquitto_cert"
|
2024-10-10 08:13:04 +00:00
|
|
|
|
|
|
|
le_key="$le_dir/privkey.pem"
|
|
|
|
mosquitto_key="$mosquitto_dir/certs/privkey.pem"
|
2024-10-10 08:38:45 +00:00
|
|
|
cp "$le_key" "$mosquitto_key"
|
|
|
|
chown mosquitto:root "$mosquitto_key"
|
2024-10-10 08:13:04 +00:00
|
|
|
|
|
|
|
# Tell mosquitto to reload certs
|
|
|
|
pkill -x -HUP mosquitto
|