From 06008e59a1dfbda99eace3d5e66d194b7e8e5c38 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Fri, 4 May 2012 09:02:59 +0200 Subject: Adding a flag --force --- fripost-newalias | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'fripost-newalias') diff --git a/fripost-newalias b/fripost-newalias index e00adcb..0ca009b 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -12,7 +12,7 @@ fripost-newalias - Add a new alias to the system =head1 SYNOPSIS B [B<--verbose>] [B<--debug>] [B<--pretend>] -[I [I...]] +[B<--force>] [I [I...]] =head1 DESCRIPTION @@ -32,6 +32,11 @@ B raises an error. Only simulates the insertion. (But still query the LDAP server to ensure that the virtual domains of aliases are know, for example.) +=item B<--force> + +Force creating the creation, even if I is already an alias. Also, +disable the sending of the confirmation. + =item B<--server_host=>I The LDAP URI to connect to. @@ -127,6 +132,7 @@ GetOptions( 'bind_dn=s' => \$conf->{bind_dn}, 'bind_pw=s' => \$conf->{bind_pw}, 'pretend' => \$conf->{pretend}, + 'force' => \$conf->{force}, 'debug' => \$conf->{debug}, 'v|verbose' => \$conf->{verbose}, 'man' => sub { pod2usage(-exitstatus => 0, @@ -178,7 +184,7 @@ confirm_or_abort(); ## Insert alias into database for my $addr (@addr) { my $rs = $ldap->alias->search({ address => $addr }); - if (!$rs->count) { + if (!$rs->count or defined $conf->{force}) { if (!$ldap->user->search({ username => $addr })->count) { if (!$conf->{pretend}) { $ldap->alias->add({ address => $addr, goto => $goto, @@ -218,7 +224,7 @@ my $msg = MIME::Lite->new( Encoding => 'quoted-printable', ); -{ +unless (defined $conf->{force}) { my ($vars, $data); $vars = { addrs => \@addr, -- cgit v1.2.3