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>
This commit is contained in:
38
read_db.sh
38
read_db.sh
@@ -1,15 +1,37 @@
|
||||
#!/bin/bash -e
|
||||
read -s -p "DB-Passwort: " password;
|
||||
echo
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
raw_proto=$(echo $password | ssh fsmi "psql -A -t -h fsmi-db fsmi -c \"select datum from protokolle where ist_veroeffentlicht='f' and name is null order by datum asc\"" 2> /dev/null)
|
||||
echo $password | ssh fsmi "psql -A -t -h fsmi-db fsmi -c \"select protokoll from protokolle where ist_veroeffentlicht='f' and name is null order by datum desc limit 1\"" 2> /dev/null > data/last_proto
|
||||
: "${FSR_GEN_SSH_TO:=fsmi-login.fsmi.uni-karlsruhe.de}"
|
||||
: "${FSR_GEN_SSH:=$(test "$(hostname -d)" = "fsmi.uni-karlsruhe.de"; echo $?)}"
|
||||
|
||||
for proto in $raw_proto;
|
||||
do
|
||||
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"
|
||||
echo "$proto" > data/last_date
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user