Mathieu Trossevin
0ca31b91fe
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|2654|8|2646|8|:-1:
Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/411//ansiblelint">Evolix » ansible-roles » unstable #411</a>
gitea/ansible-roles/pipeline/head This commit looks good
When we use a separate certificate for POP3 and IMAP there might be blank characters (almost certainly spaces but might as well be more lax) before `ssl_cert` which resulted in these lines not being detected and the hook not being played, forcing manual intervention. This commit fixes that problem by accepting blank characters before ssl_certs. (`\b` might be even better...)
45 lines
1 KiB
Bash
45 lines
1 KiB
Bash
#!/bin/sh
|
|
|
|
error() {
|
|
>&2 echo "${PROGNAME}: $1"
|
|
exit 1
|
|
}
|
|
debug() {
|
|
if [ "${VERBOSE}" = "1" ] && [ "${QUIET}" != "1" ]; then
|
|
>&2 echo "${PROGNAME}: $1"
|
|
fi
|
|
}
|
|
daemon_found_and_running() {
|
|
test -n "$(pidof dovecot)" && test -n "${doveconf_bin}"
|
|
}
|
|
config_check() {
|
|
${doveconf_bin} > /dev/null 2>&1
|
|
}
|
|
letsencrypt_used() {
|
|
${doveconf_bin} | grep -E "^[[:blank:]]*ssl_cert[^_]" | grep -q "letsencrypt"
|
|
}
|
|
main() {
|
|
if daemon_found_and_running; then
|
|
if letsencrypt_used; then
|
|
if config_check; then
|
|
debug "Dovecot detected... reloading"
|
|
systemctl reload dovecot
|
|
else
|
|
error "Dovecot config is broken, you must fix it !"
|
|
fi
|
|
else
|
|
debug "Dovecot doesn't use Let's Encrypt certificate. Skip."
|
|
fi
|
|
else
|
|
debug "Dovecot is not running or missing. Skip."
|
|
fi
|
|
}
|
|
|
|
readonly PROGNAME=$(basename "$0")
|
|
readonly VERBOSE=${VERBOSE:-"0"}
|
|
readonly QUIET=${QUIET:-"0"}
|
|
|
|
readonly doveconf_bin=$(command -v doveconf)
|
|
|
|
main
|