Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bin/ca-renew-cert
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,10 @@ Options:
__EOT__
}

remove_leading_zeros() {
sed 's/^0\+//'
}

short="hf:t:d:"
long="help,config:,type:,days:"
opts=$( getopt -o "$short" -l "$long" -n "$PROGNAME" -- "$@" )
Expand DownExpand Up@@ -58,10 +62,10 @@ SERIAL=$( openssl x509 -in "$CRT" -noout -serial | cut -d= -f2 )
# these dates are "<year> <day of year>"
export TZ=UTC
NOWYEAR=$( date +%Y )
NOWDAYS=$( date +%j )
NOWDAYS=$( date +%j | remove_leading_zeros )
# XXX: this only works with GNU date, BSD portability fail.
ENDYEAR=$( date +%Y -d "$ENDDATE + $CA_CRT_DAYS days" )
ENDDAYS=$( date +%j -d "$ENDDATE + $CA_CRT_DAYS days" )
ENDDAYS=$( date +%j -d "$ENDDATE + $CA_CRT_DAYS days" | remove_leading_zeros )
CERTDATE=$( date +%Y-%m-%d -d "$ENDDATE" )

# and this does the maths to work out how many days there are from now
Expand Down