Files
fsr_generator/read_db.sh
Tobias Wiese 6f5325678f cleanup of the presentation generation process
Clean up some bash scripts, that are used for the generation of the
presentation.

Some improvements:
* Only ssh to fsmi-login if not already running on a fsmi host.
* Use the defined postgresql service instead of manually specifing the host
* Fix bugs that could occure when having spaces in filenames
* Find the fslogo.png in the root when generating the presentation

Signed-off-by: Tobias Wiese <tobias@tobiaswiese.com>
2021-04-28 01:36:32 +02:00

38 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
set -e
: "${FSR_GEN_SSH_TO:=fsmi-login.fsmi.uni-karlsruhe.de}"
: "${FSR_GEN_SSH:=$(test "$(hostname -d)" = "fsmi.uni-karlsruhe.de"; echo $?)}"
sql() {
# $1: select
# $2: order_by
select="$1"
order_by="$2"
printf "
SELECT %s FROM protokolle
WHERE ist_veroeffentlicht=false AND name IS NULL
ORDER BY %s
" "$select" "$order_by" | tr '\n' ' '
}
cmd="psql --no-align --tuples-only service=fsmi -c"
cmd_raw="$cmd '$(sql "datum" "datum ASC")'"
cmd_last="$cmd '$(sql "protokoll" "datum DESC LIMIT 1")'"
if [ -z "$FSR_GEN_SSH" ] || [ "$FSR_GEN_SSH" -eq 0 ]; then
raw_proto="$(sh -c "$cmd_raw")"
sh -c "$cmd_last" >data/last_proto
else
raw_proto="$(ssh -- "$FSR_GEN_SSH_TO" "$cmd_raw")"
ssh -- "$FSR_GEN_SSH_TO" "$cmd_last" >data/last_proto
fi
for proto in $raw_proto; do
echo "* FSR-Protokoll vom $proto"
done > data/uvproto.txt
echo "$proto" > data/last_date
grep -oP '(?<=nächste Redeleitung: ).*(?=</li>)' data/last_proto > data/redeleitung
grep -oP '(?<=nächstes Protokoll: ).*(?=</li>)' data/last_proto > data/protokoll