mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-04-12 00:03:17 +02:00
13 lines
500 B
Bash
13 lines
500 B
Bash
#/bin/sh
|
|
|
|
set -euo pipefail
|
|
|
|
# Validate host:port
|
|
if ! echo $1 | grep -qP '^(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})|(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])):\d{1,5}$'; then
|
|
echo "Invalid host:port"
|
|
exit 1
|
|
fi
|
|
|
|
echo $((($(echo -n | openssl s_client -connect $1 2>/dev/null | openssl x509 -noout -enddate | sed "s/.*=\(.*\)/\1/" | xargs -I __ date -d "__" +%s) - $(date +%s))/86400))
|
|
|