From e289fd71191117a57a15b36e94fdf2ab3aeef7a8 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Thu, 31 Aug 2023 17:38:46 +0200 Subject: [PATCH] =?UTF-8?q?j'ai=20refait=20le=20script=20par=20rapport=20a?= =?UTF-8?q?ux=20autres=20mod=C3=A8les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- certbot/files/hooks/deploy/proftpd.sh | 46 ++++++++++++++++++--------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/certbot/files/hooks/deploy/proftpd.sh b/certbot/files/hooks/deploy/proftpd.sh index 2a28fb07..1921458c 100755 --- a/certbot/files/hooks/deploy/proftpd.sh +++ b/certbot/files/hooks/deploy/proftpd.sh @@ -1,11 +1,5 @@ #!/bin/sh -readonly PROGNAME=$(basename "$0") -readonly ARGS=$@ - -readonly VERBOSE=${VERBOSE:-"0"} -readonly QUIET=${QUIET:-"0"} - error() { >&2 echo "${PROGNAME}: $1" exit 1 @@ -15,14 +9,36 @@ debug() { >&2 echo "${PROGNAME}: $1" fi } - -if [ -n "$(pidof proftpd)" ]; then - if $($(command -v proftpd) -t 2> /dev/null); then - debug "ProFTPD detected... reloading" - service proftpd reload +daemon_found_and_running() { + test -n "$(pidof proftpd)" && test -n "${proftpd_bin}" +} +config_check() { + ${proftpd_bin} configtest > /dev/null 2>&1 +} +letsencrypt_used() { + grep -q -r -E "letsencrypt" /etc/proftpd/ +} +main() { + if daemon_found_and_running; then + if letsencrypt_used; then + if config_check; then + debug "ProFTPD detected... reloading" + systemctl reload proftpd + else + error "ProFTPD config is broken, you must fix it !" + fi + else + debug "ProFTPD doesn't use Let's Encrypt certificate. Skip." + fi else - error "ProFTPD config is broken, you must fix it !" + debug "ProFTPD is not running or missing. Skip." fi -else - debug "ProFTPD is not running. Skip." -fi +} + +readonly PROGNAME=$(basename "$0") +readonly VERBOSE=${VERBOSE:-"0"} +readonly QUIET=${QUIET:-"0"} + +readonly proftpd_bin=$(command -v proftpd) + +main