e-smith-ibays/root/etc/e-smith/events/actions/group-ibay-modify

31 lines
764 B
Perl
Executable File

#!/usr/bin/perl -w
use strict;
use esmith::AccountsDB;
use esmith::event;
my $accounts = esmith::AccountsDB->open() or
die "Unable to open accounts db: $!";
my ($self, $groupName) = @ARGV;
# Find all "i-bay" entries in the e-smith accounts database and
# if the group matches this one, change it to group "admin".
my @modified_ibays;
foreach my $ibay ( $accounts->ibays ) {
if ( $ibay->prop('Group') eq $groupName ) {
$ibay->set_prop( 'Group', 'admin' );
push @modified_ibays, $ibay->key;
event_signal("ibay-modify-files", $ibay->key) or
die ("Error occurred while updating i-bay.\n");
}
}
my $count = @modified_ibays;
if ( $count > 0 ) {
event_signal("ibay-modify-servers" ) or
die ("Error occurred after updating i-bays.\n");
}