2021-01-01 19:35:55 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-03-05 16:18:59 +01:00
|
|
|
# This script is executed by make in the parent directory
|
|
|
|
|
2021-01-01 19:35:55 +01:00
|
|
|
[ "$HOSTNAME" != lime2 ] || exit 1
|
2021-01-01 19:22:33 +01:00
|
|
|
|
2021-02-28 18:40:33 +01:00
|
|
|
awk -v header="$(<./header.html)" '{sub(/===HEADER===/,header)} 1' ./procedures/index.template.html |
|
|
|
|
awk -v footer="$(<./footer.html)" '{sub(/===FOOTER===/,footer)} 1' > ./procedures/index.tmp.html
|
2021-01-03 21:43:15 +01:00
|
|
|
|
2021-01-01 19:22:33 +01:00
|
|
|
for folder in ~/tssr/procedures/*; do
|
|
|
|
if [ -d "$folder" ]; then
|
2021-01-01 19:56:20 +01:00
|
|
|
name=$(basename "$folder")
|
2021-01-07 21:46:06 +01:00
|
|
|
display_name=$(echo "$name" | sed -E 's/procedure_//g; s/_202.+//g; s/-/ /g; s/_/ /g')
|
2021-01-03 21:43:15 +01:00
|
|
|
if [[ "$name" = *chose* ]]; then # ignore procedure_chose
|
2021-03-12 12:23:00 +01:00
|
|
|
if [ "$VERBOSE" = true ]; then
|
|
|
|
echo "Ignoring ${name}"
|
|
|
|
fi
|
2021-01-01 21:05:23 +01:00
|
|
|
else
|
2021-03-12 12:23:00 +01:00
|
|
|
if [ "$VERBOSE" = true ]; then
|
|
|
|
echo -n "Pulling ${name}..."
|
|
|
|
fi
|
2021-02-16 16:36:12 +01:00
|
|
|
if [[ ! "$name" = *tablette* ]]; then
|
|
|
|
origin_file_time=$(stat -c %Y "$folder"/procedure*.pdf)
|
2021-02-28 18:40:33 +01:00
|
|
|
current_file_time=$(stat -c %Y ./procedures/procedure_"$name".pdf)
|
2021-02-16 16:36:12 +01:00
|
|
|
fi
|
|
|
|
if [ -z "$current_file_time" ] || [ "$origin_file_time" -gt "$current_file_time" ]; then
|
2021-03-12 12:23:00 +01:00
|
|
|
cp "$folder"/procedure*.pdf ./procedures/procedure_"$name".pdf && echo "Updated $name"
|
2021-02-03 11:59:21 +01:00
|
|
|
else
|
2021-03-12 12:23:00 +01:00
|
|
|
if [ "$VERBOSE" = true ]; then
|
|
|
|
echo "Already up to date"
|
|
|
|
fi
|
2021-02-03 11:59:21 +01:00
|
|
|
fi
|
2021-02-28 18:40:33 +01:00
|
|
|
sed -i "s@===PROCEDURE===@<li><p><a href='./procedure_${name}.pdf'>${display_name}</a></p></li>\n===PROCEDURE===@g" ./procedures/index.tmp.html
|
2021-01-01 21:05:23 +01:00
|
|
|
fi
|
2021-01-01 19:22:33 +01:00
|
|
|
fi
|
|
|
|
done
|
2021-01-03 21:43:15 +01:00
|
|
|
|
2021-02-28 18:40:33 +01:00
|
|
|
chmod 644 ./procedures/index.html
|
2021-01-13 12:51:43 +01:00
|
|
|
|
2021-03-12 12:23:00 +01:00
|
|
|
sed 's/===PROCEDURE===//g' ./procedures/index.tmp.html > ./procedures/index.html && rm ./procedures/index.tmp.html
|
2021-01-03 21:43:15 +01:00
|
|
|
|
2021-02-28 18:40:33 +01:00
|
|
|
chmod 444 ./procedures/index.html
|