Skip to content

Instantly share code, notes, and snippets.

@baszoetekouw
Last active September 30, 2016 08:30
Show Gist options
  • Save baszoetekouw/f47011561f5da88b45493427ef69b547 to your computer and use it in GitHub Desktop.
Save baszoetekouw/f47011561f5da88b45493427ef69b547 to your computer and use it in GitHub Desktop.
Fetch a specific entity from edugain
#!/bin/sh
set -e
MDS=http://mds.edugain.org/
MDSCACHE=/tmp/edugain.mds.xml
MAXAGE=3600
ENTITY=$1
AGE=$(expr $MAXAGE + 1)
if [ -e $MDSCACHE ]; then
AGE=$(expr $(date +%s) - $(stat -c %Y $MDSCACHE))
fi
if [ $AGE -gt $MAXAGE ]; then
echo "Refreshing eduGAIN MDS (age: $AGE)"
curl --silent -o $MDSCACHE $MDS
fi
head -n2 $MDSCACHE
xpath -e "//md:EntityDescriptor[@entityID=\"$ENTITY\"]" < $MDSCACHE 2>/dev/null
tail -n1 $MDSCACHE
echo
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment