Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

convert-passwd-to-postfixadmin.pl 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/perl -w
  2. #
  3. # Postfix Admin
  4. #
  5. # LICENSE
  6. # This source file is subject to the GPL license that is bundled with
  7. # this package in the file LICENSE.TXT.
  8. #
  9. # Further details on the project are available at http://postfixadmin.sf.net
  10. #
  11. # @version $Id$
  12. # @license GNU GPL v2 or later.
  13. #
  14. #
  15. # Really crude attempt at taking all users from a local
  16. # passwd file (/etc/shadow) and creating postfixadmin mailboxes for them.
  17. #
  18. # The script outputs some SQL, which you need to then insert into your database
  19. # as appropriate.
  20. #
  21. # Notes:
  22. # 1) Change $mydomain and $true as required.
  23. # 2) Ideally it should parse /etc/passwd, or call the getpw()? function and
  24. # populate someone's name if known.
  25. # 3) There's plenty of room for improvement.
  26. #
  27. # Original author: David Goodwin <david at palepurple-co-uk> - 2007/10/05.
  28. #
  29. use strict;
  30. open(FH, '</etc/shadow') or die ('Cannot open shadow file; you need to be root - ' . $!);
  31. my $mydomain = "test.com";
  32. my $true = "t"; # t for pgsql; 1 for mysql
  33. foreach(<FH>) {
  34. my ($username, $password) = split(':', $_);
  35. next if $password eq '!';
  36. next if $password eq '*';
  37. my $maildir = "$username\@$mydomain/";
  38. print "insert into mailbox (username, password, domain, active, maildir) values ('$username', '$password', '$mydomain', $true, '$maildir');\n";
  39. }