diff options
author | Michael Reed <michael@michaelreed.io> | 2017-07-09 03:31:58 -0400 |
---|---|---|
committer | Michael Reed <michael@michaelreed.io> | 2017-07-09 03:49:48 -0400 |
commit | 59293cc7c60688d5b34a038805a33dbdbd2133d3 (patch) | |
tree | 7929d48749c304d37935bcba2095b291e50ff5d5 /www | |
parent | e07fe644fb9d1cadb137a57d6aad836cfd6bef83 (diff) | |
download | librebootfr-59293cc7c60688d5b34a038805a33dbdbd2133d3.tar.gz librebootfr-59293cc7c60688d5b34a038805a33dbdbd2133d3.zip |
www/publish.sh: Make safe to run multiple instances concurrently
Instead of always using the same file (temp.md), use a unique temporary
file so that multiple instances of publish.sh do not clobber each
other's work.
Diffstat (limited to 'www')
-rwxr-xr-x | www/publish.sh | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/www/publish.sh b/www/publish.sh index 264c95a1..40140728 100755 --- a/www/publish.sh +++ b/www/publish.sh @@ -2,6 +2,7 @@ # # Copyright (C) 2017 Alyssa Rosenzweig <alyssa@rosenzweig.io> # Copyright (C) 2017 Leah Rowe <info@minifree.org> +# Copyright (C) 2017 Michael Reed <michael@michaelreed.io> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,8 +22,9 @@ set -e printf '%s\n' $1 FILE=${1%.md} +TMPFILE=$(mktemp -t libreboot_www.XXXXXXXXXX) -cat $1 > temp.md +cat "$1" > "$TMPFILE" OPTS="-T Libreboot" @@ -46,29 +48,29 @@ else fi if [[ $FILE = *suppliers ]]; then - printf '\n%s\n' "<strong><a href=\"/git.html#editing-the-website-and-documentation-wiki-style\">Edit this page</a></strong> -- <a href=\"../\">Back to previous page</a>" >> temp.md + printf '\n%s\n' "<strong><a href=\"/git.html#editing-the-website-and-documentation-wiki-style\">Edit this page</a></strong> -- <a href=\"../\">Back to previous page</a>" >> "$TMPFILE" fi if [ "${FILE}" != "./docs/fdl-1.3" ] && [ "${FILE}" != "./conduct" ]; then - cat footer.md >> temp.md + cat footer.md >> "$TMPFILE" fi # change out .md -> .html -sed -i -e 's/\.md\(#[a-z\-]*\)*)/.html\1)/g' temp.md -sed -i -e 's/\.md\(#[a-z\-]*\)*]/.html\1]/g' temp.md +sed -i -e 's/\.md\(#[a-z\-]*\)*)/.html\1)/g' "$TMPFILE" +sed -i -e 's/\.md\(#[a-z\-]*\)*]/.html\1]/g' "$TMPFILE" # change out .md -> .html -sed -i -e 's/\.md\(#[a-z\-]*\)*)/.html\1)/g' temp.md -sed -i -e 's/\.md\(#[a-z\-]*\)*]/.html\1]/g' temp.md +sed -i -e 's/\.md\(#[a-z\-]*\)*)/.html\1)/g' "$TMPFILE" +sed -i -e 's/\.md\(#[a-z\-]*\)*]/.html\1]/g' "$TMPFILE" # work around issue #2872 -TOC=$(grep -q "^x-toc-enable: true$" temp.md && printf '%s\n' "--toc --toc-depth=2") || TOC="" +TOC=$(grep -q "^x-toc-enable: true$" "$TMPFILE" && printf '%s\n' "--toc --toc-depth=2") || TOC="" # work around heterogenous pandoc versions SMART=$(pandoc -v | grep -q '2\.0' || printf '%s\n' "--smart") || SMART="" # chuck through pandoc -pandoc $TOC $SMART temp.md -s --css /global.css $OPTS \ +pandoc $TOC $SMART "$TMPFILE" -s --css /global.css $OPTS \ --template template.html --metadata return="$RETURN"> $FILE.html # additionally, produce bare file for RSS @@ -76,3 +78,6 @@ pandoc $1 > $FILE.bare.html # generate section title anchors as [link] sed -i -e 's_^<h\([123]\) id="\(.*\)">\(.*\)</h\1>_<div class="h"><h\1 id="\2">\3</h\1><a aria-hidden="true" href="#\2">[link]</a></div>_' $FILE.html + +# clean up temporary file +rm -f "$TMPFILE" |