bugfix
This commit is contained in:
29
validity.sh
29
validity.sh
@@ -5,7 +5,8 @@
|
||||
|
||||
VERSION="v1.0"
|
||||
|
||||
red="\033[1;31m"
|
||||
redbold="\033[1;31m"
|
||||
red="\033[10;31m"
|
||||
greenbold="\033[1;32m"
|
||||
green="\033[0;32m"
|
||||
yellow="\033[0;33m"
|
||||
@@ -48,13 +49,14 @@ ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbi
|
||||
|
||||
### Domains to check ###
|
||||
#hosts=("domain.com")
|
||||
hosts=("")
|
||||
if [ ${#hosts[@]} -eq 0 ]; then
|
||||
hosts=()
|
||||
#if [ ${#hosts[@]} -eq 0 ]; then
|
||||
if [ -f "$ScriptWorkDir/validity_domains.txt" ]; then
|
||||
readarray -t hosts < "$ScriptWorkDir/validity_domains.txt"
|
||||
else echo -e "${red}No domain to check !${reset}"
|
||||
fi
|
||||
fi
|
||||
#fi
|
||||
|
||||
port=443
|
||||
# Days left before notification
|
||||
nday=15
|
||||
@@ -98,9 +100,24 @@ send_pushover_notification() {
|
||||
|
||||
|
||||
for host in "${hosts[@]}"; do
|
||||
|
||||
url="https://$host"
|
||||
response=$(curl --connect-timeout 10 --max-time 10 --retry 3 --retry-delay 0 --retry-max-time 30 --write-out '%{http_code}' --silent --output /dev/null "$url")
|
||||
|
||||
if [ $(grep -w "200\|301\|302\|303\|307" <<< "$response") ];then
|
||||
|
||||
if command -v showcert >/dev/null 2>&1; then
|
||||
|
||||
cert=$(showcert $host)
|
||||
|
||||
: << 'COMMENTS2'
|
||||
error=$(echo "$cert" | grep "Verification error (use -i)")
|
||||
if [ -n "$error" ]; then
|
||||
echo -e "${redbold}$error${reset}\n${italic}Trying showcert -i $host${reset}"
|
||||
cert=$(showcert -i $host)
|
||||
fi
|
||||
COMMENTS2
|
||||
|
||||
ip=$(echo "$cert" | grep IP | awk -F": " '{print $2}')
|
||||
names=$(echo "$cert" | grep Names | awk -F": " '{print $2}')
|
||||
issuer=$(echo "$cert" | grep Issuer | awk -F": " '{print $2}')
|
||||
@@ -162,4 +179,8 @@ for host in "${hosts[@]}"; do
|
||||
|
||||
echo -e "\n"
|
||||
sleep 1
|
||||
|
||||
else
|
||||
echo -e "${red}$host is offline !${reset}"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user