aboutsummaryrefslogtreecommitdiffstats
path: root/fripost-newalias
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-05-04 09:02:59 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-05-04 09:02:59 +0200
commit06008e59a1dfbda99eace3d5e66d194b7e8e5c38 (patch)
tree5e8aa1dde4792b8523b4bef4005aef89afd69802 /fripost-newalias
parent8bbf67de5056e1a0ee59dc1ff104223ec32df2f2 (diff)
Adding a flag --force
Diffstat (limited to 'fripost-newalias')
-rwxr-xr-xfripost-newalias12
1 files changed, 9 insertions, 3 deletions
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<fripost-newalias> [B<--verbose>] [B<--debug>] [B<--pretend>]
-[I<goto> [I<from>...]]
+[B<--force>] [I<goto> [I<from>...]]
=head1 DESCRIPTION
@@ -32,6 +32,11 @@ B<fripost-newalias> 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<from> is already an alias. Also,
+disable the sending of the confirmation.
+
=item B<--server_host=>I<host>
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,