blob: 11bd6852c27db9e9cfe97ba1d95fc82c8219a84b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/bash
error()
{
echo "Error: $*"
exit 1
}
if [ -z "$1" ]; then
echo "$0 <Filename / id from metadata to remove>"
exit
fi
metadataurl=$1
if [ -s "${metadataurl}" ]; then
entityidfn=$(basename $metadataurl)
else
case $metadataurl in
[0-9][0-9]*)
url="https://metadata.swamid.se/?rawXML=${metadataurl}"
;;
https://metadata.swamid.se/?showEntity=*)
url=$(echo "$metadataurl" | sed 's;showEntity;rawXML;')
;;
esac
metadata=`curl -L -m 5 -s -k -f "${url}"`
[ -n "$metadata" ] || error "Failed to fetch metadata from $metadataurl"
entityid=`echo "$metadata" | sed -n 's/.*entityID=['\''"]\([^"]*\)['\''"].*/\1/p'`
[ -n "$entityid" ] || error "Failed to find entityID in metadata"
[ `echo "$entityid" | wc -l` = 1 ] || error "Multiple entityid:s found: `echo $entityid`"
entityidfn=`echo "$entityid" | sed 's;.*://;;' | sed 's/[^a-zwA-ZW0-9_.-]/-/g' | sed 's/$/.xml/'`
[ -n "$entityidfn" ] || error "Failed to generate filename from entityid $entityid"
fi
file="swamid-2.0/$entityidfn"
if [ -r "$file" ]; then
echo "---------------------"
grep "/$entityidfn" *.mxml sp-with-simplesign
echo "---------------------"
echo -n "OK to remove ? [Y/n]"
read x
case $x in
"Y"|"y"|"") ;;
*) exit 1 ;;
esac
echo
if (grep -q $entityidfn sp-with-simplesign); then
sed -i.bak "/\/$entityidfn/d" sp-with-simplesign
if [ -f sp-with-simplesign.bak ]; then
rm sp-with-simplesign.bak
fi
fi
git rm $file
grep $file *.mxml | sed 's/\(.*\.mxml\): <xi:include href=".*"\/>/\1/' | while read mxmlfile ; do
sed -i.bak "/\/$entityidfn/d" $mxmlfile
if [ -f $mxmlfile.bak ]; then
rm $mxmlfile.bak
fi
done
git diff
git status
else
error "File not found: $file"
fi
|