-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into production
- Loading branch information
Showing
11 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use perunServicesInit; | ||
use perunServicesUtils; | ||
use File::Basename; | ||
use JSON::XS; | ||
|
||
local $::SERVICE_NAME = basename($0); | ||
local $::PROTOCOL_VERSION = "3.0.0"; | ||
my $SCRIPT_VERSION = "3.0.0"; | ||
|
||
perunServicesInit::init; | ||
my $DIRECTORY = perunServicesInit::getDirectory; | ||
my $data = perunServicesInit::getHashedHierarchicalData; | ||
|
||
our $A_USER_LOGIN; *A_USER_LOGIN = \'urn:perun:user_facility:attribute-def:virt:login'; | ||
our $A_RESOURCE_UMBRACO_GROUP_NAME; *A_RESOURCE_UMBRACO_GROUP_NAME = \'urn:perun:resource:attribute-def:def:umbracoGroupName'; | ||
|
||
my $siteStruc = {}; | ||
|
||
foreach my $resourceId ($data->getResourceIds()) { | ||
my $groupName = $data->getResourceAttributeValue(resource => $resourceId, attrName => $A_RESOURCE_UMBRACO_GROUP_NAME ); | ||
next unless $groupName; | ||
|
||
foreach my $memberId ($data->getMemberIdsForResource( resource => $resourceId )) { | ||
my $login = $data->getUserFacilityAttributeValue( member => $memberId, attrName => $A_USER_LOGIN ); | ||
$siteStruc->{$groupName}->{$login} = 1; | ||
} | ||
} | ||
|
||
###Prepare struc for printing to JSON | ||
my @printingStruc = (); | ||
foreach my $groupName (sort keys %$siteStruc) { | ||
my $record = {}; | ||
$record->{'groupName'} = $groupName; | ||
my @members = (); | ||
foreach my $login (sort keys %{$siteStruc->{$groupName}}) { | ||
push @members, $login; | ||
} | ||
$record->{'members'} = \@members; | ||
push @printingStruc, $record; | ||
} | ||
#sort the struc to get comparable otuput | ||
@printingStruc = sort { $a->{'groupName'} cmp $b->{'groupName'} } @printingStruc; | ||
|
||
my $file_name = "$DIRECTORY/$::SERVICE_NAME"; | ||
####### output file ###################### | ||
open FILE,">$file_name" or die "Cannot open $file_name: $! \n"; | ||
print FILE JSON::XS->new->utf8->pretty->canonical->encode(\@printingStruc); | ||
close(FILE); | ||
|
||
perunServicesInit::finalize; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use warnings; | ||
use perunServicesInit; | ||
use perunServicesUtils; | ||
use File::Basename; | ||
use utf8; | ||
|
||
binmode STDOUT, ":utf8"; | ||
|
||
our $SERVICE_NAME = basename($0); | ||
our $PROTOCOL_VERSION = "3.0.0"; | ||
my $SCRIPT_VERSION = "3.0.0"; | ||
|
||
perunServicesInit::init; | ||
my $DIRECTORY = perunServicesInit::getDirectory; | ||
my $data = perunServicesInit::getHashedHierarchicalData; | ||
|
||
#Constants | ||
our $A_MEMBER_MAILS; *A_MEMBER_MAILS = \'urn:perun:member:attribute-def:virt:mails'; | ||
|
||
my $service_file_name = "$DIRECTORY/$::SERVICE_NAME"; | ||
|
||
my $emailsStruc = {}; | ||
|
||
##################################### | ||
foreach my $memberId ($data->getMemberIdsForFacility()) { | ||
my $emails = $data->getMemberAttributeValue(attrName => $A_MEMBER_MAILS, member => $memberId); | ||
foreach my $email (@$emails) { | ||
$emailsStruc->{$email} = 1; | ||
} | ||
} | ||
|
||
####### FILE WITH EMAILS ###### | ||
open SERVICE_FILE,">$service_file_name" or die "Cannot open $service_file_name: $! \n"; | ||
binmode SERVICE_FILE, ":utf8"; | ||
|
||
foreach my $email (sort keys %$emailsStruc) { | ||
print SERVICE_FILE $email . "\n"; | ||
} | ||
|
||
close(SERVICE_FILE); | ||
|
||
perunServicesInit::finalize; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
SERVICE_NAME="umbraco_mu" | ||
|
||
. generic_send |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
SERVICE_NAME="users_emails" | ||
|
||
. generic_send |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
PROTOCOL_VERSION='3.0.0' | ||
|
||
function process { | ||
DST_DIR="/tmp/" | ||
|
||
### Status codes | ||
I_CHANGED=(0 "${DST_FILE} updated") | ||
E_CANNOT_COPY=(50 'Cannot copy file ${FROM_PERUN} to ${DST_DIR}/${DST_FILE}') | ||
|
||
FROM_PERUN="${WORK_DIR}/users_emails" | ||
DST_FILE="users_emails" | ||
|
||
create_lock | ||
|
||
cp "${FROM_PERUN}" "${DST_DIR}/${DST_FILE}" | ||
|
||
if [ $? -eq 0 ]; then | ||
log_msg I_CHANGED | ||
else | ||
log_msg E_CANNOT_COPY | ||
fi | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
perun-slave-process-users-emails (3.1.1) stable; urgency=low | ||
|
||
* New package version for perun-slave-process-users-emails | ||
|
||
-- Michal Stava <[email protected]> Fri, 10 Jun 2022 14:34:00 +0200 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
perun-slave-base |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
perun-slave-base |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package for perun service - users_emails |