Fix .fr TLD and add other AFNIC's TLDs compatibility
Benjamin Renard

Benjamin Renard commited on 2017-07-28 21:49:59
Showing 1 changed files, with 14 additions and 13 deletions.

... ...
@@ -21,19 +21,20 @@ then
21 21
 fi
22 22
 
23 23
 case $TLD in
24
-	fr)
25
-		STATUS="`echo -e "$WHOIS"|grep "^status:"|awk '{print $2}'`"
26
-		[ $DEBUG -eq 1 ] && echo "Status : $STATUS"
27
-		ANNIV="`echo -e "$WHOIS"|grep "^anniversary:"|awk '{print $2}'`"
28
-		[ $DEBUG -eq 1 ] && echo "Anniversary : $ANNIV"
29
-		if [ "$STATUS" != "ACTIVE" ]
30
-		then
31
-			echo "CRITICAL : $DOMAIN status is not ACTIVE (value : $STATUS) - Anniversary : $ANNIV"
32
-			exit 2
33
-		else
34
-			echo "OK : $DOMAIN anniversary is $ANNIV"
35
-			exit 0
36
-		fi
24
+	fr|re|pm|tf|yt|wf)
25
+		EXTXT=`echo -e "$WHOIS"|egrep "^Expiry Date"|tail -n 1`
26
+		[ $DEBUG -eq 1 ] && echo "Whois expire date : $EXTXT"
27
+
28
+		EXDATE=`echo $EXTXT|sed 's/ *[^:]*: *\(.*\)$/\1/'`
29
+		[ $DEBUG -eq 1 ] && echo "Expire date (in french format) : $EXDATE"
30
+
31
+		D=$( echo $EXDATE|cut -d'/' -f 1 )
32
+		M=$( echo $EXDATE|cut -d'/' -f 2 )
33
+		Y=$( echo $EXDATE|cut -d'/' -f 3 )
34
+		[ $DEBUG -eq 1 ] && echo "Parse expire date : Y=$Y / M=$M / D=$D"
35
+
36
+		EXTIME=`date +%s -d"$Y-$M-$D"`
37
+		[ $DEBUG -eq 1 ] && echo "Expire time : $EXTIME"
37 38
 	;;
38 39
 	be)
39 40
 		STATUS="`echo -e "$WHOIS"|grep "^Status:"|sed 's/Status:[ \t]*//'`"
40 41