Last active
November 22, 2018 22:54
-
-
Save stephdl/e3f65a0c433c6f1b616eb4215b35f111 to your computer and use it in GitHub Desktop.
delete-users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Copyright (C) 2018 Nethesis S.r.l. | |
# http://www.nethesis.it - support@nethesis.it | |
# | |
# This script is part of NethServer. | |
# | |
# NethServer 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 3 of the License, | |
# or any later version. | |
# | |
# NethServer 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 NethServer. If not, see <http://www.gnu.org/licenses/>. | |
# | |
use strict; | |
use esmith::event; | |
use File::Temp qw(tempfile); | |
my $file = shift; | |
my $separator = shift; | |
if($file) { | |
open(FH, "<", $file) or die; | |
} else { | |
open(FH, "-"); | |
} | |
if( ! $separator) { | |
$separator = "\t"; | |
} | |
while(<FH>) { | |
# Remove trailing whitespace: | |
chomp $_; | |
$_ =~ s/\s+$//; | |
my ($username) = split(/$separator/, $_); | |
if( ! $username) { | |
next; | |
} | |
if( ! esmith::event::event_signal('user-delete', $username) ) { | |
warn "[ERROR] Account `$username` user-delete event failed.\n"; | |
next; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment