tunuifranken.info/pull-procedures-tssr.sh

28 lines
1,015 B
Bash
Executable file

#!/bin/bash
[ "$HOSTNAME" != lime2 ] || exit 1
echo "Pulling procedures-tssr..."
awk -v header="$(<./header.html)" '{sub(/===HEADER===/,header)} 1' ./procedures-tssr/index.template.html |
awk -v footer="$(<./footer.html)" '{sub(/===FOOTER===/,footer)} 1' > ./procedures-tssr/index.tmp.html
for folder in ~/tssr/procedures/*; do
if [ -d "$folder" ]; then
name=$(basename "$folder")
if [[ "$name" = *chose* ]]; then # ignore procedure_chose
echo ignoring "$name"
else
echo found "$name"
cp "$folder"/procedure*.pdf ./procedures-tssr/procedure_"$name".pdf
git add ./procedures-tssr/procedure_"$name".pdf
sed -i "s@===PROCEDURE===@<li><p><a href='./procedure_${name}.pdf'>procedure_${name}.pdf</a></p></li>\n===PROCEDURE===@g" ./procedures-tssr/index.tmp.html
fi
fi
done
sed 's/===PROCEDURE===//g' ./procedures-tssr/index.tmp.html > ./procedures-tssr/index.html && rm ./procedures-tssr/index.tmp.html && echo "Done"
git add ./procedures-tssr/index.html
exit 0