#! perl
#
# TITLE: Local mail delivery setup
#
# $Id: admin-05local.pl.in,v 1.3 2001/07/07 16:06:53 mrsam Exp $
#
# Copyright 2001 Double Precision, Inc.  See COPYING for
# distribution information.

if ($cgi->param("Submit"))
{
    my $type=$cgi->param("defaultdeliverytype");

    my $dotforward=
	$cgi->param("dotforward") ? "|| $bindir/dotforward\n":"";

    my $cmd=
	$type eq "maildir" ? "${dotforward}./Maildir":
	    $type eq "procmail" ? "${dotforward}| $bindir/preline /usr/bin/procmail":
		$type eq "maildrop" ? "${dotforward}| $bindir/maildrop":
		    $cgi->param("defaultdeliverytxt");

    $cmd =~ s/\r//g;

    ReplaceEnvVarConfigFile("courierd", "DEFAULTDELIVERY", $cmd);
    changed("courier stop", "courier start");
}

my $vars=ReadEnvVarConfigFile("courierd");

my $cmd=$$vars{'DEFAULTDELIVERY'};

display_form("admin-05local.html",
	     {
		 "DEFAULTDELIVERY" =>
		     (
		      "<tt><textarea cols=\"75\" rows=\"4\" name=\"defaultdeliverytxt\">"
		      . htmlescape($cmd)
		      . "</textarea></tt>"
		      )
		     }
	     );
