Added procedure and install script from hedgedoc
This commit is contained in:
parent
f88e3ae400
commit
e147522141
15
README.md
15
README.md
|
|
@ -1,2 +1,13 @@
|
||||||
Test
|
# Lamapoll DSGVO Script
|
||||||
Test2
|
|
||||||
|
## Testdaten:
|
||||||
|
"Vorname: Jonathan"
|
||||||
|
"Nachname: Fraine"
|
||||||
|
"Username: meinungsbilder"
|
||||||
|
"Email: markus.winkler@wikimedia.de"
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# fact checking
|
||||||
|
PATH="$(pwd)"
|
||||||
|
USER="$(stat -c '%U' $PATH/lamapolldsgvo.desktop)"
|
||||||
|
|
||||||
|
# install .desktop file
|
||||||
|
install -m 644 $PATH/lamapolldsgvo.desktop -o root -g root /usr/share/applications/lamapolldsgvo.desktop
|
||||||
|
|
||||||
|
#cp $PATH/lamapolldsgvo.desktop /usr/share/applications/lamapolldsgvo.desktop
|
||||||
|
#chown root:root /usr/share/applications/lamapolldsgvo.desktop
|
||||||
|
#chmod 644 /usr/share/applications/lamapolldsgvo.desktop
|
||||||
|
|
||||||
|
# install actual script
|
||||||
|
install -m 775 $PATH/lamapoll-DSGVO.sh -o root -g root /usr/local/bin/lamapoll-DSGVO.sh
|
||||||
|
|
||||||
|
#cp $PATH/lamapoll-DSGVO.sh /usr/local/bin/lamapoll-DSGVO.sh
|
||||||
|
#chown root:root /usr/local/bin/lamapoll-DSGVO.sh
|
||||||
|
#chmod 775 /usr/local/bin/lamapoll-DSGVO.sh
|
||||||
|
|
||||||
|
# install link into start menu
|
||||||
|
sudo -u $USER "desktop-file-install --dir=/home/$USER/.local/share/applications /usr/share/applications/lamapoll-dsgvo.desktop"
|
||||||
|
sudo -u $USER "update-desktop-database -v ~/.local/share/applications"
|
||||||
|
|
||||||
|
echo "Installation done."
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
file_path="/tmp/api.keys"h
|
||||||
|
|
||||||
|
if ! test -f $file_path; then
|
||||||
|
echo "Keine API Keys gefunden. Bitte eine 'api.keys' Datei in /tmp/ ablegen"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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:-}
|
||||||
|
read -p "Nachname [wird nicht gesucht wenn leer]: " NACHNAME
|
||||||
|
NACHNAME=${NACHNAME:-}
|
||||||
|
read -p "Username [wird nicht gesucht wenn leer]: " USERNAME
|
||||||
|
USERNAME=${USERNAME:-}
|
||||||
|
read -p "Email [wird nicht gesucht wenn leer]: " EMAIL
|
||||||
|
EMAIL=${EMAIL:-}
|
||||||
|
|
||||||
|
echo "Starte Suche, kann eine Weile dauern"
|
||||||
|
|
||||||
|
old_IFS="$IFS"
|
||||||
|
IFS=$'\n'
|
||||||
|
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
|
||||||
|
|
||||||
|
# filter surveys for values and extract id, pollId, name, email
|
||||||
|
rm -f /tmp/results-survey-$line-adress.json
|
||||||
|
echo "[]" > /tmp/results-survey-$line-adress.json
|
||||||
|
vars=("VORNAME" "NACHNAME" "USERNAME" "EMAIL")
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# filter double finds
|
||||||
|
jq 'sort_by(.pollId, .id) | unique_by(.pollId, .id)' /tmp/results-survey-$line-adress.json > /tmp/tmp.json && mv /tmp/tmp.json /tmp/results-survey-$line-adress.json
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
cat /tmp/survey-$line-freetext.json | tr -cd '\11\12\40-\176' > /tmp/survey-$line-freetext-removed.json
|
||||||
|
rm /tmp/survey-$line-freetext.json
|
||||||
|
mv /tmp/survey-$line-freetext-removed.json /tmp/survey-$line-freetext.json
|
||||||
|
|
||||||
|
rm -f /tmp/results-survey-$line-freetext.json
|
||||||
|
echo "[]" > /tmp/results-survey-$line-freetext.json
|
||||||
|
vars=("VORNAME" "NACHNAME" "USERNAME" "EMAIL")
|
||||||
|
for var_name in "${vars[@]}"; 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
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
IFS="$old_IFS"
|
||||||
|
|
||||||
|
echo "Suche beendet. Ergebnisse sind:"
|
||||||
|
|
||||||
|
old_IFS="$IFS"
|
||||||
|
IFS=$'\n'
|
||||||
|
for line in $(cat "$file_path"); do
|
||||||
|
cat /tmp/results-survey-$line-adress.json
|
||||||
|
cat /tmp/results-survey-$line-freetext.json
|
||||||
|
done
|
||||||
|
IFS="$old_IFS"
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
[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"
|
||||||
|
Icon=utilities-terminal
|
||||||
|
Terminal=true
|
||||||
|
Type=Application
|
||||||
|
Categories=Utility;
|
||||||
Loading…
Reference in New Issue