From a9d203809863cb00cee12fc2c0a5c7688c3de3a1 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 5 Oct 2007 08:58:36 +0000 Subject: [PATCH] convert-passwd-to-postfixadmin.pl: initial attempt; wrote due to request by plip0 on irc git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@134 a1433add-5e2c-0410-b055-b7f2511e0802 --- ADDITIONS/convert-passwd-to-postfixadmin.pl | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ADDITIONS/convert-passwd-to-postfixadmin.pl diff --git a/ADDITIONS/convert-passwd-to-postfixadmin.pl b/ADDITIONS/convert-passwd-to-postfixadmin.pl new file mode 100644 index 00000000..1e7b42cd --- /dev/null +++ b/ADDITIONS/convert-passwd-to-postfixadmin.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w +# +# Postfix Admin +# +# LICENSE +# This source file is subject to the GPL license that is bundled with +# this package in the file LICENSE.TXT. +# +# Further details on the project are available at : +# http://www.postfixadmin.com or http://postfixadmin.sf.net +# +# @version $Id$ +# @license GNU GPL v2 or later. +# +# +# Really crude attempt at taking all users from a local +# passwd file (/etc/shadow) and creating postfixadmin mailboxes for them. +# +# The script outputs some SQL, which you need to then insert into your database +# as appropriate. +# +# Notes: +# 1) Change $mydomain and $true as required. +# 2) Ideally it should parse /etc/passwd, or call the getpw()? function and +# populate someone's name if known. +# 3) There's plenty of room for improvement. +# +# Original author: David Goodwin - 2007/10/05. +# +use strict; + +open(FH, ') { + my ($username, $password) = split(':', $_); + next if $password eq '!'; + next if $password eq '*'; + my $maildir = "$username\@$mydomain/"; + print "insert into mailbox (username, password, domain, active, maildir) values ('$username', '$password', '$mydomain', $true, '$maildir');\n"; +}