#!/bin/bash
+cleantempfiles()
+{
+ if test ! -z $template && test -e $template
+ then
+ rm $template
+ fi
+ if test ! -z $tempsig && test -e $tempsig
+ then
+ rm $tempsig
+ fi
+ if test ! -z $tempsig2 && test -e $tempsig2
+ then
+ rm $tempsig2
+ fi
+ if test ! -z $oldtemp && test -e $oldtemp
+ then
+ rm $oldtemp
+ fi
+}
+
function findfiles() {
exception=""
if [ $author -eq 1 ]
exception="-not -name author-signature.xml"
fi
- echo $(find . -type f $exception -not -name 'signature*.xml' -not -name '*.wgt' | sed -e 's,^\.\/,,' | sed -f /usr/bin/url-encode.sed)
+ echo $(find . -type f $exception -not -name 'signature*.xml' | sed -e 's,^\.\/,,' | sed -f /usr/bin/url-encode.sed)
}
. $(dirname $0)/realpath.sh
if test "$ret" != "0"
then
echo "Failed to generate Author Signature. [$ret]"
+ cleantempfiles
exit $ret
fi
else
if test "$ret" != "0"
then
echo "Failed to generate Distributor Signature. [$ret]"
+ cleantempfiles
exit $ret
fi
fi
if test "$ret" != "0"
then
echo "Failed to generate Author Signature. [$ret]"
+ cleantempfiles
exit $ret
fi
fi
if test "$ret" != "0"
then
echo "Failed to generate Distributor Signature. [$ret]"
+ cleantempfiles
exit $ret
fi
xmlstarlet ed -P -N s="http://www.w3.org/2000/09/xmldsig#" -m "//s:Signature/s:KeyInfo/s:X509Data/s:X509Certificate[1]" "//s:Signature/s:KeyInfo/s:X509Data" $tempsig2 > $outname
if test "$ret" != "0"
then
echo "Failed to generate Distributor Signature. [$ret]"
+ cleantempfiles
exit $ret
fi
chmod 744 $outname
rm -rf $wgtdir
fi
-echo Signed $1
\ No newline at end of file
+echo Signed $1
+
+cleantempfiles