Projet

Général

Profil

Révision 292cfb95

ID292cfb955ae6c3c902df73f42f7e5f320f93fc92
Parent 70f565c5
Enfant 0a4891fc

Ajouté par Lars Kruse il y a presque 6 ans

ssl-certificate-expiry: add support for FreeBSD's "date"

Thanks to oz42

Closes: #1038

Voir les différences:

plugins/ssl/ssl-certificate-expiry
94 94
        valid_until_string=$(echo "$input_data" | openssl x509 -noout -enddate \
95 95
            | grep "^notAfter=" | cut -f 2 -d "=")
96 96
        if [ -n "$valid_until_string" ]; then
97
            valid_until_epoch=$(date --date="$valid_until_string" +%s)
98
            if [ -n "$valid_until_epoch" ]; then
97
            # FreeBSD requires special arguments for "date"
98
            if uname | grep -q ^FreeBSD; then
99
                valid_until_epoch=$(date -j -f '%b %e %T %Y %Z' "$valid_until_string" +%s)
100
                now_epoch=$(date -j +%s)
101
            else
102
                valid_until_epoch=$(date --date="$valid_until_string" +%s)
99 103
                now_epoch=$(date +%s)
104
            fi
105
            if [ -n "$valid_until_epoch" ]; then
100 106
                # calculate the number of days left
101 107
                echo "$valid_until_epoch" "$now_epoch" | awk '{ print(($1 - $2) / (24 * 3600)); }'
102 108
            fi

Formats disponibles : Unified diff