initial commit of file from CVS for smeserver-mailsorting on Sat Sep 7 19:56:19 AEST 2024
This commit is contained in:
41
root/etc/e-smith/events/actions/mailsorting-cleanup
Normal file
41
root/etc/e-smith/events/actions/mailsorting-cleanup
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-2001 e-smith, inc.
|
||||
#
|
||||
# Author: Stephen Noble
|
||||
# Contributor: Darrell May
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith;
|
||||
|
||||
use strict;
|
||||
use Errno;
|
||||
use esmith::config;
|
||||
use esmith::util;
|
||||
use esmith::db;
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
my $event = $ARGV [0];
|
||||
my $userName = $ARGV [1];
|
||||
die "Username argument missing." unless defined ($userName);
|
||||
|
||||
db_delete(\%processmail, $userName);
|
||||
|
||||
#get all users rules
|
||||
my @userRules = ();
|
||||
foreach (sort keys %processmail)
|
||||
{
|
||||
push (@userRules, $_)
|
||||
if (db_get_type(\%processmail, $_) eq "$userName");
|
||||
}
|
||||
|
||||
foreach (sort @userRules)
|
||||
{
|
||||
db_delete(\%processmail, $_);
|
||||
}
|
||||
|
||||
exit (0);
|
90
root/etc/e-smith/events/actions/mailsorting-update-user
Normal file
90
root/etc/e-smith/events/actions/mailsorting-update-user
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-2005 Mitel Networks Corporation
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith;
|
||||
|
||||
use strict;
|
||||
use Errno;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::templates;
|
||||
|
||||
my $accountsdb = esmith::AccountsDB->open_ro or
|
||||
die "Could not open accounts db\n";
|
||||
|
||||
my $event = shift;
|
||||
my $userName = shift;
|
||||
my @users;
|
||||
|
||||
if (defined $userName)
|
||||
{
|
||||
my $user = $accountsdb->get($userName);
|
||||
die
|
||||
"Account $userName is not a user account; update mailsorting failed.\n"
|
||||
unless ($user && $user->prop('type') eq "user" || $userName eq "admin");
|
||||
@users = ($user);
|
||||
my $geekmode = $user->prop('geekmode') || 'disabled';
|
||||
if($geekmode eq "enabled"){
|
||||
print "User $userName in geek mode, do not update mailfilter and procmail rules.\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@users = ( $accountsdb->users );
|
||||
push(@users, $accountsdb->get('admin'));
|
||||
}
|
||||
|
||||
foreach my $userName (@users)
|
||||
{
|
||||
$userName = $userName->key;
|
||||
my $geekmode = $accountsdb->get_prop ($userName,'geekmode') || 'disabled';
|
||||
if ( $geekmode eq "enabled" )
|
||||
{
|
||||
print "User $userName in geek mode, do not update mailfilter and procmail rules.\n";
|
||||
next;
|
||||
}
|
||||
|
||||
for my $dotfile ( qw(.procmailrc .mailfilter) )
|
||||
{
|
||||
my $pathtohome = ($userName eq 'admin')? "/home/e-smith":"/home/e-smith/files/users/$userName";
|
||||
|
||||
esmith::templates::processTemplate (
|
||||
{
|
||||
MORE_DATA =>
|
||||
{
|
||||
USERNAME => $userName ,
|
||||
},
|
||||
TEMPLATE_PATH => "/$dotfile",
|
||||
TEMPLATE_EXPAND_QUEUE =>
|
||||
[
|
||||
"/etc/e-smith/templates-user-custom",
|
||||
"/etc/e-smith/templates-user",
|
||||
],
|
||||
OUTPUT_PREFIX => $pathtohome,
|
||||
UID => $userName,
|
||||
GID => $userName,
|
||||
PERMS => 0600,
|
||||
} );
|
||||
};
|
||||
}
|
||||
|
||||
exit (0);
|
Reference in New Issue
Block a user