forked from chiyu1468/AirTrapMine
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
792 B
Bash
28 lines
792 B
Bash
#!/bin/bash
|
|
|
|
# 網站清單
|
|
DOMAINS=("google.com" "smarter.nchu.edu.tw")
|
|
|
|
echo "網站 SSL 憑證剩餘天數:"
|
|
echo "---------------------------"
|
|
|
|
for domain in "${DOMAINS[@]}"; do
|
|
end_date=$(echo | openssl s_client -servername "$domain" -connect "$domain:443" 2>/dev/null |
|
|
openssl x509 -noout -enddate | cut -d= -f2)
|
|
|
|
end_timestamp=$(date -d "$end_date" +%s)
|
|
now_timestamp=$(date +%s)
|
|
|
|
remaining_days=$(( (end_timestamp - now_timestamp) / 86400 ))
|
|
|
|
if [ $remaining_days -lt 0 ]; then
|
|
status="已過期 ❌"
|
|
elif [ $remaining_days -lt 15 ]; then
|
|
status="即將到期 ⚠️"
|
|
else
|
|
status="正常 ✅"
|
|
fi
|
|
|
|
printf "%-20s 到期日:%-25s 剩餘天數:%3d 天 %s\n" "$domain" "$end_date" "$remaining_days" "$status"
|
|
done
|