initial commit of file from CVS for smeserver-expire-accounts on Sat Sep 7 19:52:48 AEST 2024
This commit is contained in:
48
root/etc/e-smith/events/actions/user-expire-account
Normal file
48
root/etc/e-smith/events/actions/user-expire-account
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::event;
|
||||
use DateTime;
|
||||
|
||||
my $a = esmith::AccountsDB->open or
|
||||
die "Could not open AccountsDB\n";
|
||||
|
||||
my $event = shift;
|
||||
my $userName = shift;
|
||||
my @users;
|
||||
|
||||
if (defined $userName){
|
||||
my $user = $a->get($userName);
|
||||
die "Account $userName is not a user account; can't update the auto-reply message.\n"
|
||||
unless $user && $user->prop('type') eq "user";
|
||||
@users = ($user);
|
||||
}
|
||||
else{
|
||||
@users = ( $a->users );
|
||||
}
|
||||
|
||||
my $now = DateTime->now;
|
||||
|
||||
foreach my $user (@users){
|
||||
my $userName = $user->key;
|
||||
|
||||
# Remove user from all its groups
|
||||
my @groups = $a->user_group_list($userName);
|
||||
$a->remove_user_from_groups($userName, @groups);
|
||||
event_signal('group-modify', @groups) if (scalar @groups);
|
||||
|
||||
# Set forward if needed
|
||||
my $fwd = $user->prop('ExpireForwardAfterLock') || '';
|
||||
if ($fwd ne ''){
|
||||
$user->set_prop('ForwardAddress', $fwd);
|
||||
$user->set_prop('EmailForward', 'forward');
|
||||
}
|
||||
# Remove expiration settings now that the account is locked
|
||||
$user->delete_prop('ExpireLockOn');
|
||||
$user->delete_prop('ExpireLastNotifiedOn');
|
||||
# Set the expiration date
|
||||
$user->set_prop('ExpireLockedOn', $now->ymd);
|
||||
}
|
||||
|
||||
exit (0);
|
20
root/etc/e-smith/events/actions/user-reset-expired
Normal file
20
root/etc/e-smith/events/actions/user-reset-expired
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use esmith::AccountsDB;
|
||||
use User::pwent;
|
||||
|
||||
my $a = esmith::AccountsDB->open || die "Couldn't open the AccountsDB\n";
|
||||
|
||||
my $event = $ARGV[0];
|
||||
my $user = $ARGV[1];
|
||||
|
||||
if (!$event){
|
||||
die "Event must be specified\n";
|
||||
}
|
||||
if (!$user){
|
||||
die "User must be specified\n";
|
||||
}
|
||||
|
||||
my $rec = $a->get($user) || die "user $user not found in AccountsDB\n";
|
||||
$rec->delete_prop('ExpireLockedOn');
|
48
root/etc/e-smith/events/actions/user-update-auto-response
Normal file
48
root/etc/e-smith/events/actions/user-update-auto-response
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::templates;
|
||||
use esmith::util;
|
||||
use User::pwent;
|
||||
|
||||
my $a = esmith::AccountsDB->open or
|
||||
die "Could not open AccountsDB\n";
|
||||
|
||||
my $event = shift;
|
||||
my $userName = shift;
|
||||
my @users;
|
||||
|
||||
if (defined $userName){
|
||||
my $user = $a->get($userName);
|
||||
die "Account $userName is not a user account; can't update the auto-reply message.\n"
|
||||
unless $user && $user->prop('type') eq "user";
|
||||
@users = ($user);
|
||||
}
|
||||
else{
|
||||
@users = ( $a->users );
|
||||
}
|
||||
|
||||
foreach my $user (@users){
|
||||
my $userName = $user->key;
|
||||
|
||||
my $home = getpwnam($userName)->dir;
|
||||
unless (-d $home . '/.lock-auto-reply'){
|
||||
mkdir $home . '/.lock-auto-reply';
|
||||
esmith::util::chownFile($userName, $userName, $home . '/.lock-auto-reply');
|
||||
}
|
||||
|
||||
esmith::templates::processTemplate ({
|
||||
MORE_DATA => { USERNAME => $userName },
|
||||
TEMPLATE_PATH => "/.lock-auto-reply/message.txt",
|
||||
TEMPLATE_EXPAND_QUEUE =>
|
||||
[
|
||||
"/etc/e-smith/templates-user-custom",
|
||||
"/etc/e-smith/templates-user",
|
||||
],
|
||||
OUTPUT_PREFIX => "$home",
|
||||
PERMS => 0644,
|
||||
});
|
||||
}
|
||||
|
||||
exit(0);
|
Reference in New Issue
Block a user