Skip to content
This repository has been archived by the owner on Mar 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from weyhmueller/master
Browse files Browse the repository at this point in the history
Makes ssl-expiry-date compatible with BSD tools (mktemp and make)

Thanks for the contribution; increased portability is a good thing.
  • Loading branch information
skx committed Aug 31, 2013
2 parents 7d04650 + dfa186e commit 815184d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions ssl-expiry-date
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ fi
#
# Make a temporary file
#
tmp=$(mktemp)
# Test if we have BSD or GNU version of mktemp
if ( strings $(which mktemp) | grep -q GNU); then
#We have the GNU version
tmp=$(mktemp)
else
#We have the BSD version
tmp=$(mktemp -t tmp)
fi


#
Expand All @@ -68,7 +75,21 @@ rm -f "$tmp"
#
# Convert the expiry date + todays date to seconds-past epoch
#
then=$(date --date="$date" +%s)
# Check if we have the BSD or the GNU version of date
if (strings $(which date) | grep -q GNU); then
# We have GNU this is easy
then=$(date --date "$date" +%s)
else
# We have BSD now it is getting complicated
year=$(echo $date | awk '{print $4}')
month=$(echo $date | awk '{print $1}')
day=$(echo $date | awk '{print $2}')
hour=$(echo $date | awk '{print $3}' | awk -F: '{print $1}')
minute=$(echo $date | awk '{print $3}' | awk -F: '{print $2}')
second=$(echo $date | awk '{print $3}' | awk -F: '{print $3}')
then=$(date -v${year}y -v${month} -v${day}d -v${hour}H -v${minute}M -v${second}S -u +%s)
fi

now=$(date +%s)

#
Expand Down

0 comments on commit 815184d

Please sign in to comment.