From a89ebd176f9ed06221abc232ec4afe1c3d0ad504 Mon Sep 17 00:00:00 2001 From: Bruno Zell Date: Fri, 28 Sep 2018 17:48:31 +0200 Subject: [PATCH] fix function return --- src/scripts/entrypoint.sh | 2 +- src/scripts/util.sh | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/scripts/entrypoint.sh b/src/scripts/entrypoint.sh index 1235b54..3317d39 100644 --- a/src/scripts/entrypoint.sh +++ b/src/scripts/entrypoint.sh @@ -27,7 +27,7 @@ last_renewal_file="/etc/letsencrypt/last_renewal.txt" # Instead of trying to run `cron` or something like that, just sleep and run `certbot`. while [ true ]; do - if [ is_renewal_required $last_renewal_file ]; then + if is_renewal_required $last_renewal_file; then # Recreate the file to persist the last renewal timestamp touch "$last_renewal_file" diff --git a/src/scripts/util.sh b/src/scripts/util.sh index 693107d..d03a0d2 100644 --- a/src/scripts/util.sh +++ b/src/scripts/util.sh @@ -80,9 +80,7 @@ get_certificate() { # required (last renewal ran over a week ago), return false otherwise is_renewal_required() { # If the file does not exist assume a renewal is required - if [ ! -e "$1" ]; then - return true - fi + [[ ! -e "$1" ]] && return; # If the file exists, check if the last renewal was more than a week ago one_week_sec=604800 @@ -90,5 +88,5 @@ is_renewal_required() { last_renewal_sec=$(stat -c %Y "$1") last_renewal_delta_sec=$(( ($now_sec - $last_renewal_sec) )) is_finshed_week_sec=$(( ($one_week_sec - $last_renewal_delta_sec) )) - return $is_finshed_week_sec -lt 0 + [[ $is_finshed_week_sec -lt 0 ]] }