#!/bin/bash
echo Liste des membres et statut de leur inscription
for member in *euros; do
	GPGOUTPUT=$(gpg --output - $member 2>&1 | sed 's/ <.*>//g' | grep -v 'gpg: *aka')
	OUTPUT=$(echo "$GPGOUTPUT" | tail -n1)
	SIGNINFO=$(echo "$GPGOUTPUT" | sed '$d')
	EXPIREDATE=$(date --date="$(echo "$OUTPUT" | grep -o '[0-9]*/[0-9]*/[0-9]*' | sed -r 's/([0-9]*)\/([0-9]*)\/([0-9]*)/\2\/\1\/\3/') 1 year" +%Y%m%d)
	RENEWINGDATE=$(date --date="$(echo "$OUTPUT" | grep -o '[0-9]*/[0-9]*/[0-9]*' | sed -r 's/([0-9]*)\/([0-9]*)\/([0-9]*)/\2\/\1\/\3/') 350 days" +%Y%m%d)
	CURRENTDATE=$(date +%Y%m%d)

	echo
	echo -n "$OUTPUT" ; echo " -> $(date --date="$EXPIREDATE" +%d/%m/%Y)" 
	if [ "$CURRENTDATE" -ge "$EXPIREDATE" ]; then
		echo "DATE LIMITE DEPASSEE"
		continue
	fi
	if [ "$CURRENTDATE" -ge "$RENEWINGDATE" ]; then
		echo "DATE DE RENOUVELLEMENT PROCHE"
	fi
	echo "$SIGNINFO"
done
