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:
Tobias Wiese
2021-04-28 01:31:01 +02:00
committed by Yannik Enss
parent 1c9eb8535d
commit 6f5325678f
4 changed files with 40 additions and 16 deletions

View File

@@ -138,7 +138,7 @@ if __name__ == "__main__":
parser.add_argument("--send-mail", action="store_true")
args = parser.parse_args()
config = yaml.full_load(open(args.config))
config = yaml.safe_load(open(args.config))
if config["redeleitung"]["name"].startswith("./"):
with open(config["redeleitung"]["name"]) as f:

View File

@@ -1,16 +1,18 @@
#!/bin/bash
dest_file="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/data/presentation_$(date +%Y-%m-%d).tex"
#!/bin/sh
set -e
dest_file="$(realpath "$(dirname "$0")")/data/presentation_$(date +%Y-%m-%d).tex"
echo Reading old protocols
./read_db.sh
echo Getting E-Mail
./read_ubmails.py
echo Generating
./generate.py --presentation > $dest_file
./generate.py --presentation >"$dest_file"
echo Compiling
mkdir -p data/presentation
cd data/presentation/
pdflatex $dest_file > /dev/null
pdflatex $dest_file > /dev/null
pdflatex $dest_file > /dev/null
for _ in $(seq 3); do
pdflatex "$dest_file"
done

View File

@@ -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

View File

@@ -22,7 +22,7 @@
\title{Fachschaftsrat Mathe/Info}
\author{Redeleitung: {{redeleitung.name}} \\Protokoll: {{protokoll.name}} }
\date{ {{date.strftime("%d.%m.%Y")}} }
\logo{\includegraphics[width=17mm]{fslogo}}
\logo{\includegraphics[width=17mm]{../../fslogo}}
\begin{document}
\begin{frame}