-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config reloader script for reloading TLS certs/keys
- Loading branch information
Showing
5 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
: "${CONFIG_RELOADER_ENABLED:=false}" | ||
|
||
if [[ "${CONFIG_RELOADER_ENABLED}" == "true" ]]; then | ||
# Shutdown everything and exit the process crashes or is stopped. | ||
s6-svscanctl -t /etc/s6 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script watches the known TLS cert and keys for changes (`mv` or updated Kubernetes secret) then reloads postfix. | ||
|
||
: "${CONFIG_RELOADER_ENABLED:=false}" | ||
|
||
if [[ "${CONFIG_RELOADER_ENABLED}" != "true" ]]; then | ||
echo "config-reloader >> Config reloader is not being started" | ||
s6-svc -d "$(pwd)" | ||
exit | ||
fi | ||
|
||
watch_files=( | ||
"${TLS_CRT:-/etc/ssl/certs/ssl-cert-snakeoil.pem}" | ||
"${TLS_KEY:-/etc/ssl/private/ssl-cert-snakeoil.key}" | ||
"${CLIENT_TLS_KEY:-/etc/ssl/certs/ssl-cert-snakeoil.pem}" | ||
"${CLIENT_TLS_CRT:-/etc/ssl/private/ssl-cert-snakeoil.key}" | ||
) | ||
|
||
# Start infinite loop | ||
while true; do | ||
postfix reload | ||
echo "config-reloader >> Waiting on config changes..." | ||
# delete_self is the event that triggers when the link is removed and replaced. | ||
inotifywait --event delete_self "${watch_files[@]}" | ||
# sleep to prevent race condition | ||
sleep 3 | ||
done |