Browse Source

Use absolute path to 'date'

pull/19/head
srvrco 8 years ago
parent
commit
4fe4e7f398
1 changed files with 14 additions and 7 deletions
  1. +14
    -7
      checkssl

+ 14
- 7
checkssl View File

@ -47,14 +47,21 @@
# 2017-02-06 merge branches parsing CN and wildcard certs (1.17)
# 2017-02-22 make no output when -u is only arg and no upgrade available (1.18)
# 2017-12-09 Set LC_TIME to be able to parse english month (1.19)
# 2017-12-09 Use absolute path to `date` binary (1.20)
# ---------------------------------------------------------------------------
PROGNAME=${0##*/}
VERSION="1.19"
VERSION="1.20"
ORIGCMD="$0 $*"
CODE_LOCATION="https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl"
RENEW_ALERT="30" # set to number of days to be alerted for certificate renewal ( default, can be changed with -expires argument)
BIN_DATE="/bin/date"
if [[ ! -x "$BIN_DATE" ]]; then
BIN_DATE=$(command -v date || echo date)
fi
_QUIET=0
_UPGRADE=0
_UPGRADE_CHECK=1
@ -67,9 +74,9 @@ clean_up() { # Perform pre-exit housekeeping
date_diff() { # use different grep version for different os types
if [[ "$os" == "freebsd" ]]; then
date -v -${RENEW_ALERT}
"$BIN_DATE" -v -${RENEW_ALERT}
else
date -d "${RENEW_ALERT} days" +%s
"$BIN_DATE" -d "${RENEW_ALERT} days" +%s
fi
}
@ -118,7 +125,7 @@ usage() {
}
log() {
echo "[$(date +%Y-%m-%d\ %H:%M:%S)] $*" >> "${PROGNAME}.log"
echo "[$("$BIN_DATE" +%Y-%m-%d\ %H:%M:%S)] $*" >> "${PROGNAME}.log"
}
debug() {
@ -389,15 +396,15 @@ while IFS= read -r LINE; do
fi
if [[ "$ENDDATE" != "-" ]]; then
if [[ "$os" == "bsd" ]]; then
if [[ $(date -v +"${RENEW_ALERT}d" +%s) -gt $(LC_TIME=C date -j -f "%b %d %H:%M:%S %Y %Z" "$ENDDATE" +%s) ]]; then
if [[ $("$BIN_DATE" -v +"${RENEW_ALERT}d" +%s) -gt $(LC_TIME=C "$BIN_DATE" -j -f "%b %d %H:%M:%S %Y %Z" "$ENDDATE" +%s) ]]; then
PROBLEMS=$(echo "${PROBLEMS}- certificate near renewal date")
fi
elif [[ "$os" == "mac" ]]; then
if [[ $(date -v +"${RENEW_ALERT}d" +%s) -gt $(LC_TIME=C date -j -f "%b %d %H:%M:%S %Y %Z" "$ENDDATE" +%s) ]]; then
if [[ $("$BIN_DATE" -v +"${RENEW_ALERT}d" +%s) -gt $(LC_TIME=C "$BIN_DATE" -j -f "%b %d %H:%M:%S %Y %Z" "$ENDDATE" +%s) ]]; then
PROBLEMS=$(echo "${PROBLEMS}- certificate near renewal date")
fi
else
if [[ $(date -d "${RENEW_ALERT} days" +%s) -gt $(LC_TIME=C date -d "$ENDDATE" +%s) ]]; then
if [[ $("$BIN_DATE" -d "${RENEW_ALERT} days" +%s) -gt $(LC_TIME=C "$BIN_DATE" -d "$ENDDATE" +%s) ]]; then
PROBLEMS=$(echo "${PROBLEMS}- certificate near renewal date")
fi
fi


Loading…
Cancel
Save