Prevent concurrent executions of the feed generator

This commit is contained in:
~lucidiot 2024-01-19 14:28:09 +00:00
parent 5c13229bcd
commit a5d7575384
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
1 changed files with 10 additions and 0 deletions

View File

@ -78,6 +78,14 @@ function log {
}
[ -z "$DIR" ] && DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -e "$DIR/.itsb-feedgen" ]; then
echo "The lockfile at $DIR/.itsb-feedgen already exists."
exit 1
fi
log Creating lockfile at "$DIR/.itsb-feedgen"
touch "$DIR/.itsb-feedgen"
trap "rm -f \"$DIR/.itsb-feedgen\"" EXIT INT TERM
log Building to $DIR/feeds
mkdir -p $DIR/feeds
@ -98,6 +106,8 @@ fi
<xsl:text>
</xsl:text>
<xsl:apply-templates select="//itsb:feed[not(itsb:link)]" />
<xsl:text><![CDATA[
rm "$DIR/.itsb-feedgen"]]></xsl:text>
</xsl:template>
<xsl:template match="itsb:feed[not(itsb:link)]">