Skip to content
Snippets Groups Projects
Commit 1e76d807 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update renew: exit code 0 if renew was skipped

parent 97d071c9
Branches
No related tags found
No related merge requests found
......@@ -44,11 +44,16 @@ function _listCerts(){
$ACME --list
}
# internal function; get a list of fqdn of all existing certs
function _listCertdomains(){
_listCerts | sed -n '2,$p' | awk '{ print $1 }'
}
# internal function; checks if a certificate for a given FQDN already exists
# used in _certMustExist, _certMustNotExist
# param string FQDN
function _certExists(){
_listCerts | awk '{ print $1 }' | grep "^${CM_fqdn}$" >/dev/null
_listCertdomains | grep "^${CM_fqdn}$" >/dev/null
}
# internal function; a certificate of a given FQDN must exist - otherwise
......@@ -306,30 +311,34 @@ function public_list(){
function public_renew(){
_requiresFqdn
_certMustExist
$ACME --renew -d ${CM_fqdn} $ACME_Params || exit 2
_certTransfer
_certMatching
$ACME --renew -d ${CM_fqdn} $ACME_Params
local _rc=$?
_update "renewed ${CM_fqdn}"
case $_rc in
0)
_certTransfer
_certMatching
_update "renewed ${CM_fqdn}"
;;
2)
_wd "renew was skipped ... we need to wait a while."
;;
*)
_wd "Error ocured."
exit $_rc
esac
}
#
# public function - renew al certificates (to be used in cronjon)
# public function - renew all certificates (to be used in a cronjob)
# no params
function public_renew-all(){
_listCerts | sed -n '2,$p' | awk '{ print $1 }' | while read mydomain
_listCertdomains | while read mydomain
do
_wd "--- renew $mydomain"
_setenv ${mydomain}
$ACME --renew -d ${CM_fqdn} $ACME_Params
if [ $? -eq 0 ]; then
_certTransfer
_certMatching
_update "renewed ${CM_fqdn}"
fi
public_renew
done
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment