freedombone-rmemail 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # Removes an email address rule from the email configuration
  10. #
  11. # License
  12. # =======
  13. #
  14. # Copyright (C) 2015-2018 Bob Mottram <bob@freedombone.net>
  15. #
  16. # This program is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU Affero General Public License as published by
  18. # the Free Software Foundation, either version 3 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Affero General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU Affero General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. PROJECT_NAME='freedombone'
  29. export TEXTDOMAIN=${PROJECT_NAME}-rmemail
  30. export TEXTDOMAINDIR="/usr/share/locale"
  31. MYUSERNAME=$USER
  32. function show_help {
  33. echo ''
  34. echo $"${PROJECT_NAME}-rmemail -u [username] -e [email address]"
  35. echo ''
  36. exit 0
  37. }
  38. while [ $# -gt 1 ]
  39. do
  40. key="$1"
  41. case $key in
  42. -h|--help)
  43. show_help
  44. ;;
  45. -u|--user)
  46. shift
  47. MYUSERNAME="$1"
  48. ;;
  49. -e|--email)
  50. shift
  51. EMAILADDRESS="$1"
  52. ;;
  53. *)
  54. # unknown option
  55. ;;
  56. esac
  57. shift
  58. done
  59. if ! [[ $MYUSERNAME && $EMAILADDRESS ]]; then
  60. show_help
  61. fi
  62. MUTTRC="/home/$MYUSERNAME/.muttrc"
  63. PM=/home/$MYUSERNAME/.procmailrc
  64. if grep -q "Email rule for $EMAILADDRESS ->" "$PM"; then
  65. sed -i "/# Email rule for $EMAILADDRESS ->.*/,/# End of rule/d" "$PM"
  66. fi
  67. exit 0