freedombone-utils-gpg 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # gpg functions
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. function enable_email_encryption_at_rest {
  31. for d in /home/*/ ; do
  32. USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
  33. if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
  34. if grep '#/usr/bin/gpgit.pl' /home/$USERNAME/.procmailrc; then
  35. sed -i 's|#/usr/bin/gpgit.pl|/usr/bin/gpgit.pl|g' /home/$USERNAME/.procmailrc
  36. fi
  37. fi
  38. done
  39. if grep '#/usr/bin/gpgit.pl' /etc/skel/.procmailrc; then
  40. sed -i 's|#/usr/bin/gpgit.pl|/usr/bin/gpgit.pl|g' /etc/skel/.procmailrc
  41. fi
  42. }
  43. function disable_email_encryption_at_rest {
  44. for d in /home/*/ ; do
  45. USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
  46. if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
  47. if ! grep '#/usr/bin/gpgit.pl' /home/$USERNAME/.procmailrc; then
  48. sed -i 's|/usr/bin/gpgit.pl|#/usr/bin/gpgit.pl|g' /home/$USERNAME/.procmailrc
  49. fi
  50. fi
  51. done
  52. if ! grep '#/usr/bin/gpgit.pl' /etc/skel/.procmailrc; then
  53. sed -i 's|/usr/bin/gpgit.pl|#/usr/bin/gpgit.pl|g' /etc/skel/.procmailrc
  54. fi
  55. }
  56. # NOTE: deliberately no exit 0