Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

postfixadmin-domain-postdeletion.sh 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. # Example script for removing a Maildir domain top-level folder
  3. # from a Courier-IMAP virtual mail hierarchy.
  4. # The script only looks at argument 1, assuming that it
  5. # indicates the relative name of a domain, such as
  6. # "somedomain.com". If $basedir/somedomain.com exists, it will
  7. # be removed.
  8. # The script will not actually delete the directory. I moves it
  9. # to a special directory which may once in a while be cleaned up
  10. # by the system administrator.
  11. # This script should be run as the user which owns the maildirs. If
  12. # the script is actually run by the apache user (e.g. through PHP),
  13. # then you could use "sudo" to grant apache the rights to run
  14. # this script as the relevant user.
  15. # Assume this script has been saved as
  16. # /usr/local/bin/postfixadmin-domain-postdeletion.sh and has been
  17. # made executable. Now, an example /etc/sudoers line:
  18. # apache ALL=(courier) NOPASSWD: /usr/local/bin/postfixadmin-domain-postdeletion.sh
  19. # The line states that the apache user may run the script as the
  20. # user "courier" without providing a password.
  21. # Change this to where you keep your virtual mail users' maildirs.
  22. basedir=/var/spool/maildirs
  23. # Change this to where you would like deleted maildirs to reside.
  24. trashbase=/var/spool/deleted-maildirs
  25. if [ `echo $1 | fgrep '..'` ]; then
  26. echo "First argument contained a double-dot sequence; bailing out."
  27. exit 1
  28. fi
  29. if [ ! -e "$trashbase" ]; then
  30. echo "trashbase '$trashbase' does not exist; bailing out."
  31. exit 1
  32. fi
  33. trashdir="${trashbase}/`date +%F_%T`_$1"
  34. domaindir="${basedir}/$1"
  35. if [ ! -e "$domaindir" ]; then
  36. echo "Directory '$domaindir' does not exits; nothing to do."
  37. exit 0;
  38. fi
  39. if [ ! -d "$domaindir" ]; then
  40. echo "'$domaindir' is not a directory; bailing out."
  41. exit 1
  42. fi
  43. if [ -e "$trashdir" ]; then
  44. echo "Directory '$trashdir' already exits; bailing out."
  45. exit 1;
  46. fi
  47. mv $domaindir $trashdir
  48. exit $?