summaryrefslogtreecommitdiff
path: root/localaddsmtpuser
blob: 04588bacbcebfe84ec49610bbd3f73739d760d42 (plain)
  1. #!/bin/sh
  2. #
  3. # Copyright © 2015, Jonas Smedegaard <dr@jones.dk>
  4. # Description: Setup SMTP sub-account for use e.g. with nullmailer
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3, or (at your option)
  9. # any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. # General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. set -e
  20. exit1() {
  21. echo >&2 "ERROR: $1"
  22. exit 1
  23. }
  24. echo "$1" | grep -q '^[a-z][a-z0-9]*$' || exit1 "Illegal character in base username!"
  25. user="$1-smtp"
  26. desc="SMTP sub-account for $1"
  27. adduser --force-badname --no-create-home --shell /bin/false --gecos "$desc" "$user"