Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/ https://fsfe.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7KB

  1. #!/usr/bin/env bash
  2. # This script makes it easier to update the PDFreaders signatures.
  3. # 1. Save the automatically sent emails (subject: [PDFReaders] petition
  4. # signature) to a local folder. In Thunderbird, it should be
  5. # extracted as .eml file per default
  6. # 2. Copy this script in the same folder and run it.
  7. # 3. Manually check the new file (per default petition-sig.xml_NEW) if
  8. # everythings looks fine. Delete test entries
  9. # 4. Insert the new entries in /campaigns/pdfreaders/petition-sig.en.xml
  10. # and sort them alphabetically. Vim can help you with that.
  11. # Coded by Max Mehl <max.mehl@fsfe.org>
  12. # License: GNU GPL v3 and newer
  13. FINALFILE="petition-sig.xml_NEW" # In this file the result is printed
  14. rm "$FINALFILE"
  15. for f in *.eml
  16. do
  17. tr -d '\015' <"$f" >"1-$f" # Convert DOS to Unix line breaks
  18. grep -A17 "Errors-To:" "1-$f" > "2-$f" # Remove everything except the message body
  19. sed -e 's/Errors-To:.*//' -e '/./!d' "2-$f" > "3-$f" # Delete last header line and empty lines
  20. # Some messages are encoded in Base64. Decode them if necessary
  21. base64 -d "3-$f" &>/dev/null
  22. if [ "$?" == 0 ]; then
  23. base64 -d "3-$f" > "4-$f"
  24. else
  25. cat "3-$f" > "4-$f"
  26. fi
  27. # Extract names and surnames and remove them from unnecessary parts
  28. NAME=$(grep "\sname=\".*\"" "4-$f")
  29. NAME=$(echo $NAME | awk -F= '{ print $2 }')
  30. NAME=$(echo $NAME | sed 's/"//g')
  31. SURNAME=$(grep "surname=\".*\"" "4-$f")
  32. SURNAME=$(echo $SURNAME | awk -F= '{ print $2 }')
  33. SURNAME=$(echo $SURNAME | sed 's/"//g')
  34. # Add <li> tags
  35. echo "<li>$NAME $SURNAME</li>" >> "$FINALFILE.temp"
  36. # remove temporary files
  37. rm 1-*.eml 2-*.eml 3-*.eml 4-*.eml
  38. done
  39. # Remove duplicate entries
  40. sort "$FINALFILE.temp" | uniq -u > "$FINALFILE"
  41. rm "$FINALFILE.temp"