freedombone-rmemail 1.9KB

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