Skip to content

Commit

Permalink
Merge pull request #701 from stavamichal/users_emails
Browse files Browse the repository at this point in the history
feat(users_emails): new scripts for getting all users mails
  • Loading branch information
stavamichal authored Jun 28, 2022
2 parents 0cde618 + ea33ebf commit 6774c71
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 0 deletions.
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;
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 6774c71

Please sign in to comment.