commit 4ff50ec956fac69f3912bf0de8746db5fe4f31c3
parent 0f9c3d2b6a9521dbe62ca0af0e35a6ef550b07d1
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 18 Dec 2025 07:43:43 +0530
parent 0f9c3d2b6a9521dbe62ca0af0e35a6ef550b07d1
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 18 Dec 2025 07:43:43 +0530
Update scripts apit and certbot2acmesh.sh
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/server/apit b/server/apit @@ -2,11 +2,11 @@ # apit - acme.sh post install tool # -# You issued certs, now where do they go? +# You issued certs from acme.sh, now where do they go? # apit solves this problem by giving you a "configuration file", # # Two problems are solved here, -# * You don't have type exorbitantly long commands and make common mistakes +# * Prevent typing exorbitantly long commands and making common mistakes # * Properly specify user/group for the certs # # =EXAMPLE= @@ -28,7 +28,7 @@ # frustrating server maintainence routine. # # =BUGS= -# Does not support -d'option' flags, use as -d 'option' +# Does not support --arg='option' syntax, use as --arg 'option' # # =LICENSE= # apit is in the public domain. @@ -43,10 +43,11 @@ set -e APIT_VERSION=0.1 # initial values -default_cert_dir=/etc/ssl/live +: ${default_cert_dir:=/etc/ssl/live} +: ${acmesh_bin:=/root/.acme.sh/acme.sh} op_action=install -panic() { echo "apit $@"; exit 1; } +panic() { echo "apit: ERR: $@"; exit 1; } usage() { echo "apit - acme.sh post install tool $1 @@ -76,7 +77,7 @@ _apit_install() { (set -x; mkdir -p "$domain_cert_dir") fi - acme.sh --install-cert -d "$1" \ + "${acmesh_bin}" --install-cert -d "$1" \ --key-file "${domain_cert_dir}/privkey.pem" \ --cert-file "${domain_cert_dir}/cert.pem" \ --fullchain-file "${domain_cert_dir}/fullchain.pem" @@ -87,6 +88,8 @@ _apit_install() { fi } +[ -f "${acmesh_bin}" ] || panic "Cannot find acme.sh in PATH" + while [ $# -ne 0 ]; do case $1 in --action) op_action="$2" ;;
diff --git a/server/certbot2acmesh.sh b/server/certbot2acmesh.sh @@ -40,14 +40,25 @@ for d in ${dom[@]}; do siteroot=$ACME_SH_ROOT/$d mkdir -p $siteroot [[ -n ${altdoms[$i]} ]] && ad=$'\n'"Le_Alt='${altdoms[$i]}'" || ad="" - renewal=$(date -u -D '%Y-%m-%d %H:%M:%S+00:00' -d "${expiry[$i]}" '+%s') - reloadcmd_b64=$(echo -n "$RELOADCMD" | base64) - renewal=$(fixexpiry $renewal 5 -30) - #renewalstr=$(date -u -D '%Y-%m-%d %H:%M:%S+00:00' -d $renewal +%FT%TZ) #-u '+%FT%TZ' - renewalstr=$(date -u -d @$renewal +%FT%TZ) #-u '+%FT%TZ' - creation=$(date +%s) - creation=$((creation - 86400 * 30)) - creationstr=$(date -d @$creation -u '+%FT%TZ') + if date --version | grep GNU; then + renewal=$(date -d "${expiry[$i]}" -u '+%s') + reloadcmd_b64=$(echo -n "$RELOADCMD" | base64) + + renewal=$(fixexpiry $renewal 5 -30) + renewalstr=$(date -d @$renewal -u '+%FT%TZ') + creation=$(date +%s) + creation=$((creation - 86400 * 30)) + creationstr=$(date -d @$creation -u '+%FT%TZ') + else + renewal=$(date -u -D '%Y-%m-%d %H:%M:%S+00:00' -d "${expiry[$i]}" '+%s') + reloadcmd_b64=$(echo -n "$RELOADCMD" | base64) + renewal=$(fixexpiry $renewal 5 -30) + #renewalstr=$(date -u -D '%Y-%m-%d %H:%M:%S+00:00' -d $renewal +%FT%TZ) #-u '+%FT%TZ' + renewalstr=$(date -u -d @$renewal +%FT%TZ) #-u '+%FT%TZ' + creation=$(date +%s) + creation=$((creation - 86400 * 30)) + creationstr=$(date -d @$creation -u '+%FT%TZ') + fi echo "New renewal date: $renewalstr" cat >$siteroot/$d.conf <<EOF
: bharatvaj/scripts