Created
October 26, 2016 11:01
-
-
Save ahgittin/0189585a359cdb772766ba2a173c1da3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for l in locations/* ; do | |
ENT=`xmlstarlet sel -t -v "location/locationConfig/callerContext/entityProxy" $l` | |
if [ ! -z "$ENT" ] ; then | |
if [ -z `find . -name $ENT` ] ; then | |
# it's a leak | |
LOC=`basename $l` | |
echo "Detected location $LOC has reference to deleted entity $ENT - removing it" | |
rm $l | |
FILES=`grep -l $LOC locations/*` | |
if [ ! -z "$FILES" ] ; then | |
echo " also referenced from $FILES - removing the references there" | |
for p in $FILES ; do | |
# finds "children" references | |
xmlstarlet ed -O -d "location/children/string[text()='"$LOC"']" $p > ${p}.bk | |
mv ${p}.bk $p | |
# finds "RebindingJcloudsLocation" references | |
xmlstarlet ed -O -d "location/locationConfig/vmInstanceIds/map/entry[locationProxy/text()= \ | |
'"$LOC"']" $p > ${p}.bk | |
mv ${p}.bk $p | |
done | |
FILES=`grep -l $LOC locations/*` | |
if [ ! -z "$FILES" ] ; then | |
echo "WARN reference to $LOC in $FILES could not be removed;" \ | |
"may need manual editing or rebind ignore instruction" | |
fi | |
fi | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment