2 Domtool (http
://hcoop
.sf
.net
/)
3 Copyright (C
) 2004 Adam Chlipala
5 This program is free software
; you can redistribute it
and/or
6 modify it under the terms
of the GNU General Public License
7 as published by the Free Software Foundation
; either version
2
8 of the License
, or (at your option
) any later version
.
10 This program is distributed
in the hope that it will be useful
,
11 but WITHOUT ANY WARRANTY
; without even the implied warranty
of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
13 GNU General Public License for more details
.
15 You should have received a copy
of the GNU General Public License
16 along
with this program
; if not
, write to the Free Software
17 Foundation
, Inc
., 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA
.
20 (* Utility to reload Courier IMAP data after modifying virtual mailboxes
*)
22 structure Reloadusers
:> RELOADUSERS
=
28 val proc
= Unix
.execute("/bin/sh", ["-c", courierDir ^
"/sbin/pw2userdb"])
29 val (stdout
, stdin
) = Unix
.streamsOf proc
31 val outf
= TextIO.openOut (userdbDir ^
"/localhost")
34 case TextIO.inputLine stdout
of
38 val tokens
= String.tokens (fn ch
=> Char.isSpace ch
orelse ch
= #
"|" orelse ch
= #
"=") line
40 fun findHome (n
::v
::rest
) =
42 TextIO.output (outf
, "|mail=" ^ v ^
"/Maildir")
47 TextIO.output (outf
, String.substring (line
, 0, size line
- 1));
50 (case Int.fromString first
of
54 TextIO.output (outf
, "\n");
60 TextIO.closeIn stdout
;
61 TextIO.closeOut stdin
;
63 if OS
.Process
.isSuccess (OS
.Process
.system (courierDir ^
"/sbin/makeuserdb")) then
64 OS
.Process
.system postReload
66 (print
"Error running makeuserdb\n";