From 95f216ffe613baadd347a5caa7a7d51511634918 Mon Sep 17 00:00:00 2001 From: Julian Hahn Date: Wed, 22 Apr 2026 10:51:45 +0200 Subject: [PATCH] =?UTF-8?q?Aktueller=20Stand=20kombiniert=20mit=20=C3=84nd?= =?UTF-8?q?erungen=20von=20gestern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 ++++++++++++- install.sh | 16 ++------------ lamapoll-DSGVO.sh | 51 ++++++++++++++++++++++++++++--------------- lamapolldsgvo.desktop | 2 +- 4 files changed, 51 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 2af7523..ea487a6 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,17 @@ Dauer des shell scripts: ca. 1h (testen mit `time ./usr/bin/lamapoll-dsgvo.sh`) ## Installation -Nach Herunterladen und Entpacken des Repositories, einfach das install.sh ausführen als Root oder mit "sudo" und das sollte sich um den Rest kümmern. \ No newline at end of file +Nach Herunterladen und Entpacken des Repositories, einfach das install.sh ausführen als Root oder mit "sudo" und das sollte sich um den Rest kümmern. + +1. Repository als .zip Herunterladen +2. zu finden unter: `home/vorname.nachname/Downloads/Lamapoll_DSGVO_script-main.zip` +3. unzippen `vorname.nachname@wmde-123456:~/Downloads$ unzip Lamapoll_DSGVO_script-main.zip` +4. In den neu enstandenen Ordner navigieren und das Installationsskript ausführbar machen: `vorname.nachname@wmde-123456:~/Downloads/lamapoll_dsgvo_script$ chmod +x install.sh` +5. Installationsskript ausführen: vorname.nachname@wmde-123456:~/Downloads/lamapoll_dsgvo_script$ sudo ./install.sh + + +## Benutzung + +Im Startmenü sollte nach der Installation der Eintrag `LamapollDSGVO` findbar sein. Beim Ausführen wird automatisch ein Terminal geöffnet, welches alle Informationen abfragt bevor die Suche startet. +Nach der Suche wird automatisch ein Text Editor geöffnet, der alle Ergebnisse zusammengefasst anzeigt. +Um Daten zu schützen, wird diese Datei nach dem Schließen des Texteditors gelöscht, genauso wie alle Zwischenergebnisse. \ No newline at end of file diff --git a/install.sh b/install.sh index b7a0059..0464a53 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # fact checking PATH="$(/usr/bin/pwd)" @@ -16,16 +16,4 @@ echo $USER /usr/bin/sudo -u $USER desktop-file-install --dir=/home/$USER/.local/share/applications /usr/share/applications/lamapolldsgvo.desktop /usr/bin/sudo -u $USER update-desktop-database -v /home/$USER/.local/share/applications -echo "Installation done." - -/usr/bin/rm -f /tmp/api.keys 2>&1 >/dev/null -/usr/bin/touch /tmp/api.keys -/usr/bin/chown $USER:$USER /tmp/api.keys -MORE="y" -while [ $MORE == "y" ]; do - read -p "Bitte API Key eingeben: " API - API=${API:-} - echo $API >> /tmp/api.keys - read -p "Weitere API Keys eingeben? [y/N] " MORE - MORE=${MORE:-N} -done \ No newline at end of file +echo "Installation done." \ No newline at end of file diff --git a/lamapoll-DSGVO.sh b/lamapoll-DSGVO.sh index 9c181ba..e323687 100644 --- a/lamapoll-DSGVO.sh +++ b/lamapoll-DSGVO.sh @@ -1,12 +1,25 @@ -#! /bin/bash +#!/bin/bash -file_path="/tmp/api.keys" +USER=$(whoami) +file_path="/home/$USER/Dokumente/api.keys" if ! test -f $file_path; then - echo "Keine API Keys gefunden. Bitte eine 'api.keys' Datei in /tmp/ ablegen" + echo "Keine API Keys gefunden. Bitte eine 'api.keys' Datei in /home/$USER/Dokumente/ ablegen" exit 1 fi +#/usr/bin/rm -f /home/$USER/Dokumente/api.keys 2>&1 >/dev/null +#/usr/bin/touch /home/$USER/Dokumente/api.keys +#/usr/bin/chown $USER:$USER /home/$USER/Dokumente/api.keys +#MORE="y" +#while [ $MORE == "y" ]; do +# read -p "Bitte API Key eingeben: " API +# API=${API:-} +# echo $API >> /tmp/api.keys +# read -p "Weitere API Keys eingeben? [y/N] " MORE +# MORE=${MORE:-N} +#done + echo "Im Folgenden werden die Daten abgefragt nach denen gesucht werden soll. Bitte mit ENTER bestätigen." read -p "Vorname [wird nicht gesucht wenn leer]: " VORNAME VORNAME=${VORNAME:-} @@ -25,9 +38,9 @@ for line in $(cat "$file_path"); do ## WMDE-Survey Respondents ("Adressbuch") rm -f /tmp/survey-$line-adress.json echo "[]" > /tmp/survey-$line-adress.json - for POLL in $(curl -s -X GET -H "Authorization: Bearer 643M34DK" https://app.lamapoll.de/api/v2/polls?limit=1000 | jq -r '.[] | .id'); do - curl -s -X GET -H "Authorization: Bearer 643M34DK" https://app.lamapoll.de/api/v2/polls/${POLL}/respondents -s | jq -r '.' > /tmp/survey-$line-adress-$POLL.json - jq '. += (inputs)' /tmp/survey-$line-adress.json /tmp/survey-$line-adress-$POLL.json > temp.json && mv temp.json /tmp/survey-$line-adress.json && rm /tmp/survey-$line-adress-$POLL.json ; done + for POLL in $(curl -s -X GET -H "Authorization: Bearer $line" https://app.lamapoll.de/api/v2/polls?limit=1000 | jq -r '.[] | .id'); do + curl -s -X GET -H "Authorization: Bearer $line" https://app.lamapoll.de/api/v2/polls/${POLL}/respondents -s | jq -r '.' > /tmp/survey-$line-adress-$POLL.json + jq '. += (inputs)' /tmp/survey-$line-adress.json /tmp/survey-$line-adress-$POLL.json > /tmp/temp.json && mv /tmp/temp.json /tmp/survey-$line-adress.json && rm /tmp/survey-$line-adress-$POLL.json ; done # filter surveys for values and extract id, pollId, name, email rm -f /tmp/results-survey-$line-adress.json @@ -36,9 +49,8 @@ for line in $(cat "$file_path"); do for var_name in "${vars[@]}"; do value="${!var_name}" if [[ -n "$value" ]]; then - echo "$var_name = $value" cat /tmp/survey-$line-adress.json | jq --arg TEST "$value" '.[] | select((.name | test($TEST; "i")) or (.email | test($TEST; "i"))) | {pollId, id, name, email}' > /tmp/survey-$line-adress-$var_name.json - jq '. += [(inputs)]' /tmp/results-survey-$line-adress.json /tmp/survey-$line-adress-$var_name.json > temp.json && mv temp.json /tmp/results-survey-$line-adress.json && rm /tmp/survey-$line-adress-$var_name.json + jq '. += [(inputs)]' /tmp/results-survey-$line-adress.json /tmp/survey-$line-adress-$var_name.json > /tmp/temp.json && mv /tmp/temp.json /tmp/results-survey-$line-adress.json && rm /tmp/survey-$line-adress-$var_name.json fi done # filter double finds @@ -47,9 +59,9 @@ for line in $(cat "$file_path"); do ## WMDE-Survey Results ("Freitextsuche") rm -f /tmp/survey-$line-freetext.json echo "[]" > /tmp/survey-$line-freetext.json - for POLL in $(curl -s -X GET -H "Authorization: Bearer 643M34DK" https://app.lamapoll.de/api/v2/polls?limit=1000 | jq -r '.[] | .id'); do - curl -s -X GET -H "Authorization: Bearer 643M34DK" https://app.lamapoll.de/api/v2/polls/${POLL}/results -s | jq --arg POLL "${POLL}" -r '. | .pollId = $POLL' > /tmp/survey-$line-freetext-$POLL.json - jq '. += [(inputs)]' /tmp/survey-$line-freetext.json /tmp/survey-$line-freetext-$POLL.json > temp.json && mv temp.json /tmp/survey-$line-freetext.json && rm /tmp/survey-$line-freetext-$POLL.json ; done + for POLL in $(curl -s -X GET -H "Authorization: Bearer $line" https://app.lamapoll.de/api/v2/polls?limit=1000 | jq -r '.[] | .id'); do + curl -s -X GET -H "Authorization: Bearer $line" https://app.lamapoll.de/api/v2/polls/${POLL}/results -s | jq --arg POLL "${POLL}" -r '. | .pollId = $POLL' > /tmp/survey-$line-freetext-$POLL.json + jq '. += [(inputs)]' /tmp/survey-$line-freetext.json /tmp/survey-$line-freetext-$POLL.json > /tmp/temp.json && mv /tmp/temp.json /tmp/survey-$line-freetext.json && rm /tmp/survey-$line-freetext-$POLL.json ; done cat /tmp/survey-$line-freetext.json | tr -cd '\11\12\40-\176' > /tmp/survey-$line-freetext-removed.json rm /tmp/survey-$line-freetext.json @@ -62,18 +74,23 @@ for line in $(cat "$file_path"); do value="${!var_name}" if [[ -n "$value" ]]; then cat /tmp/survey-$line-freetext.json | jq --arg TEST "$value" '.[] | {name: .name, pollId: .pollId, results: .results[] | select(.groups[].labels[] | test($TEST; "i")) | {question: .question, questionId: .questionId, labels: [.groups[].labels[] | select(test($TEST; "i"))]}}' > /tmp/survey-$line-freetext-$var_name.json - jq '. += [(inputs)]' /tmp/results-survey-$line-freetext.json /tmp/survey-$line-freetext-$var_name.json > temp.json && mv temp.json /tmp/results-survey-$line-freetext.json && rm /tmp/survey-$line-freetext-$var_name.json + jq '. += [(inputs)]' /tmp/results-survey-$line-freetext.json /tmp/survey-$line-freetext-$var_name.json > /tmp/temp.json && mv /tmp/temp.json /tmp/results-survey-$line-freetext.json && rm /tmp/survey-$line-freetext-$var_name.json fi done done IFS="$old_IFS" -echo "Suche beendet. Ergebnisse sind:" - old_IFS="$IFS" IFS=$'\n' +rm -f /tmp/resultfile.json 2>&1 >/dev/null +touch /tmp/resultfile.json for line in $(cat "$file_path"); do - cat /tmp/results-survey-$line-adress.json - cat /tmp/results-survey-$line-freetext.json + cat /tmp/results-survey-$line-adress.json >> /tmp/resultfile.json + echo "" >> /tmp/resultfile.json + cat /tmp/results-survey-$line-freetext.json >> /tmp/resultfile.json + echo "" >> /tmp/resultfile.json done -IFS="$old_IFS" \ No newline at end of file +IFS="$old_IFS" +/usr/bin/gnome-text-editor /tmp/resultfile.json +rm -f /tmp/resultfile.json +rm -f /tmp/results-survey*.json \ No newline at end of file diff --git a/lamapolldsgvo.desktop b/lamapolldsgvo.desktop index f6ad4f5..3329bb4 100644 --- a/lamapolldsgvo.desktop +++ b/lamapolldsgvo.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Name=LamapollDSGVO Comment=Filter all Survey answers for occurences of the searched answers -Exec=gnome-terminal -- "bash /usr/local/bin/lamapoll-DSGVO.sh" +Exec=bash /usr/local/bin/lamapoll-DSGVO.sh Icon=utilities-terminal Terminal=true Type=Application