fix function return

This commit is contained in:
Bruno Zell 2018-09-28 17:48:31 +02:00
parent 16e052dc8c
commit a89ebd176f
2 changed files with 3 additions and 5 deletions

View File

@ -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`. # Instead of trying to run `cron` or something like that, just sleep and run `certbot`.
while [ true ]; do 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 # Recreate the file to persist the last renewal timestamp
touch "$last_renewal_file" touch "$last_renewal_file"

View File

@ -80,9 +80,7 @@ get_certificate() {
# required (last renewal ran over a week ago), return false otherwise # required (last renewal ran over a week ago), return false otherwise
is_renewal_required() { is_renewal_required() {
# If the file does not exist assume a renewal is required # If the file does not exist assume a renewal is required
if [ ! -e "$1" ]; then [[ ! -e "$1" ]] && return;
return true
fi
# If the file exists, check if the last renewal was more than a week ago # If the file exists, check if the last renewal was more than a week ago
one_week_sec=604800 one_week_sec=604800
@ -90,5 +88,5 @@ is_renewal_required() {
last_renewal_sec=$(stat -c %Y "$1") last_renewal_sec=$(stat -c %Y "$1")
last_renewal_delta_sec=$(( ($now_sec - $last_renewal_sec) )) last_renewal_delta_sec=$(( ($now_sec - $last_renewal_sec) ))
is_finshed_week_sec=$(( ($one_week_sec - $last_renewal_delta_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 ]]
} }