Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Johaney-s committed Jul 11, 2022
2 parents be5e1f0 + 6774c71 commit 13fb2fd
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 2 deletions.
54 changes: 54 additions & 0 deletions gen/umbraco_mu
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;
44 changes: 44 additions & 0 deletions gen/users_emails
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;
2 changes: 1 addition & 1 deletion send/bbmri_collections
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [ "$DESTINATION_TYPE" != "url" ]; then
fi

# Read user name and password from configuration if it is present ( expect string "-u user:pass" )
[ -r /etc/perun/services/$SERVICE_NAME ] && . /etc/perun/services/$SERVICE_NAME
[ -r /etc/perun/services/$SERVICE_NAME/$SERVICE_NAME ] && . /etc/perun/services/$SERVICE_NAME/$SERVICE_NAME

# Specify command to transfer the data
TRANSPORT_COMMAND="curl -Ss -i -H Content-Type:application/json -f -X POST"
Expand Down
2 changes: 1 addition & 1 deletion send/bbmri_networks
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [ "$DESTINATION_TYPE" != "url" ]; then
fi

# Read user name and password from configuration if it is present ( expect string "-u user:pass" )
[ -r /etc/perun/services/$SERVICE_NAME ] && . /etc/perun/services/$SERVICE_NAME
[ -r /etc/perun/services/$SERVICE_NAME/$SERVICE_NAME ] && . /etc/perun/services/$SERVICE_NAME/$SERVICE_NAME

# Specify command to tranfer the data
#TRANSPORT_COMMAND="curl --cacert /etc/ssl/chain_TERENA_SSL_CA_3.pem -i -H Content-Type:application/json -f -X POST"
Expand Down
4 changes: 4 additions & 0 deletions send/umbraco_mu
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
SERVICE_NAME="umbraco_mu"

. generic_send
4 changes: 4 additions & 0 deletions send/users_emails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
SERVICE_NAME="users_emails"

. generic_send
24 changes: 24 additions & 0 deletions slave/process-users-emails/bin/process-users_emails.sh
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
}
5 changes: 5 additions & 0 deletions slave/process-users-emails/changelog
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
1 change: 1 addition & 0 deletions slave/process-users-emails/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perun-slave-base
1 change: 1 addition & 0 deletions slave/process-users-emails/rpm.dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
perun-slave-base
1 change: 1 addition & 0 deletions slave/process-users-emails/short_desc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package for perun service - users_emails

0 comments on commit 13fb2fd

Please sign in to comment.