Merge branch 'master' of ssh://cpp/liblerdorf
This commit is contained in:
commit
67d851658c
7 changed files with 124 additions and 43 deletions
1
Makefile
1
Makefile
|
|
@ -17,6 +17,7 @@ install:
|
||||||
$(COPY) -r ACU/ $(DEST)
|
$(COPY) -r ACU/ $(DEST)
|
||||||
! test -d $(GITOLITE_DEST) || $(MAKEDIR) -p $(GITOLITE_DEST)/update.secondary.d
|
! test -d $(GITOLITE_DEST) || $(MAKEDIR) -p $(GITOLITE_DEST)/update.secondary.d
|
||||||
! test -d $(GITOLITE_DEST) || $(COPY) hooks/gl-pre-git $(GITOLITE_DEST)/
|
! test -d $(GITOLITE_DEST) || $(COPY) hooks/gl-pre-git $(GITOLITE_DEST)/
|
||||||
|
! test -d $(GITOLITE_DEST) || $(COPY) hooks/post-update $(GITOLITE_DEST)/
|
||||||
! test -d $(GITOLITE_DEST) || $(COPY) hooks/subjects.pl $(GITOLITE_DEST)/update.secondary.d/
|
! test -d $(GITOLITE_DEST) || $(COPY) hooks/subjects.pl $(GITOLITE_DEST)/update.secondary.d/
|
||||||
! test -d $(GITOLITE_DEST) || $(COPY) hooks/conferences.pl $(GITOLITE_DEST)/update.secondary.d/
|
! test -d $(GITOLITE_DEST) || $(COPY) hooks/conferences.pl $(GITOLITE_DEST)/update.secondary.d/
|
||||||
! test -d $(GITOLITE_DEST) || $(COPY) hooks/submissions.pl $(GITOLITE_DEST)/update.secondary.d/
|
! test -d $(GITOLITE_DEST) || $(COPY) hooks/submissions.pl $(GITOLITE_DEST)/update.secondary.d/
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use warnings;
|
||||||
use v5.10;
|
use v5.10;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Net::IP;
|
use Net::IP;
|
||||||
|
use utf8;
|
||||||
|
|
||||||
use ACU::Log;
|
use ACU::Log;
|
||||||
$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log";
|
$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log";
|
||||||
|
|
|
||||||
96
hooks/post-update
Executable file
96
hooks/post-update
Executable file
|
|
@ -0,0 +1,96 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use v5.10;
|
||||||
|
use File::Basename;
|
||||||
|
use utf8;
|
||||||
|
|
||||||
|
use ACU::API::Projects;
|
||||||
|
use ACU::API::Submission;
|
||||||
|
use ACU::LDAP;
|
||||||
|
use ACU::Log;
|
||||||
|
$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log";
|
||||||
|
use ACU::Process;
|
||||||
|
|
||||||
|
my $promo;
|
||||||
|
my $id_project;
|
||||||
|
my $repo_login;
|
||||||
|
|
||||||
|
# First, extract information, from config then guess from repository adress
|
||||||
|
if (my $tmp = `git config hooks.promo`) { chomp $tmp; $promo = $tmp; }
|
||||||
|
if (my $tmp = `git config hooks.idproject`) { chomp $tmp; $id_project = $tmp; }
|
||||||
|
if (my $tmp = `git config hooks.login`) { chomp $tmp; $repo_login = $tmp; }
|
||||||
|
|
||||||
|
$promo = $1 if (!$promo && $ENV{'GL_REPO'} =~ m/([0-9]{4}).*/);
|
||||||
|
$id_project = $1 if (!$id_project && $ENV{'GL_REPO'} =~ m/.*\/(.*)\//);
|
||||||
|
$repo_login = $1 if (!$repo_login && $ENV{'GL_REPO'} =~ m/.*\/.*\/(.*)/);
|
||||||
|
|
||||||
|
exit(0) if (!$promo || !$id_project || !$repo_login);
|
||||||
|
|
||||||
|
for my $ref (@ARGV)
|
||||||
|
{
|
||||||
|
if ($ref =~ m<^refs/tags/(.+)$>)
|
||||||
|
{
|
||||||
|
my $tag = $1;
|
||||||
|
log DEBUG, "Tag $tag on repository $ENV{GL_REPO} from IP $ENV{'SSH_CLIENT'} updated.";
|
||||||
|
|
||||||
|
# Get project informations
|
||||||
|
my $project;
|
||||||
|
eval {
|
||||||
|
$project = API::Projects::get($id_project, $promo);
|
||||||
|
};
|
||||||
|
if ($@ or !$project)
|
||||||
|
{
|
||||||
|
my $err = $@;
|
||||||
|
log TRACE, $err;
|
||||||
|
log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire.";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extract lot of data
|
||||||
|
my @rendus = grep {
|
||||||
|
exists $_->{vcs} and $_->{vcs}{tag} eq $tag;
|
||||||
|
} @{ $project->{submissions} };
|
||||||
|
|
||||||
|
if (@rendus)
|
||||||
|
{
|
||||||
|
eval
|
||||||
|
{
|
||||||
|
Process::Client::launch("send_git",
|
||||||
|
{
|
||||||
|
"year" => $promo,
|
||||||
|
"id" => $id_project,
|
||||||
|
"rendu" => $tag,
|
||||||
|
"login" => $repo_login,
|
||||||
|
# "path" => "ssh://git\@localhost/".$ENV{GL_REPO}, # Optional
|
||||||
|
},
|
||||||
|
undef, # Don't give any file
|
||||||
|
1 # Launch in background
|
||||||
|
);
|
||||||
|
};
|
||||||
|
if ($@)
|
||||||
|
{
|
||||||
|
my $err = $@;
|
||||||
|
log DEBUG, "ERROR: ".$err;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send data to API
|
||||||
|
my $last_commit = `git log "refs/tags/$tag" -1 --decorate --tags`;
|
||||||
|
eval {
|
||||||
|
API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit);
|
||||||
|
};
|
||||||
|
if ($@)
|
||||||
|
{
|
||||||
|
my $err = $@;
|
||||||
|
log DEBUG, "ERROR: ".$err;
|
||||||
|
log DONE, "Tag '$tag' effectué avec succès !";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
@ -52,7 +52,7 @@ if ($ref =~ m<^refs/tags/(.+)$>)
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
log TRACE, $err;
|
log TRACE, $err;
|
||||||
log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire.";
|
log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire.";
|
||||||
exit 1;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
log TRACE, $project;
|
log TRACE, $project;
|
||||||
|
|
@ -119,40 +119,13 @@ if ($ref =~ m<^refs/tags/(.+)$>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($newsha eq '0' x 40) {
|
if (@rendus && $newsha eq '0' x 40)
|
||||||
log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
eval {
|
log USAGE, "Mais pour quelle raison voudriez-vous supprimer un tag ?!";
|
||||||
Process::Client::launch("send_git",
|
exit(7);
|
||||||
{
|
|
||||||
"year" => $promo,
|
|
||||||
"id" => $id_project,
|
|
||||||
"rendu" => $tag,
|
|
||||||
"login" => $repo_login,
|
|
||||||
# "path" => "ssh://git\@localhost/".$ENV{GL_REPO},
|
|
||||||
}, undef, 1);
|
|
||||||
};
|
|
||||||
if ($@) {
|
|
||||||
my $err = $@;
|
|
||||||
log DEBUG, "ERROR: ".$err;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Send data to API
|
|
||||||
my $last_commit = `git log $newsha -1 --decorate --tags`;
|
|
||||||
eval {
|
|
||||||
API::Submission::add($promo, $id_project, $tag, $repo_login, $last_commit);
|
|
||||||
};
|
|
||||||
if ($@) {
|
|
||||||
my $err = $@;
|
|
||||||
log DEBUG, "ERROR: ".$err;
|
|
||||||
log DONE, "Tag '$tag' effectué avec succès !";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log DONE, "Tag '$tag' effectué avec succès ! Vérifiez-le sur l'intranet.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
# elsif @rendus : new rendu => accepted
|
||||||
|
# else user defined tag => accepted
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
|
||||||
|
|
@ -121,13 +121,13 @@ sub master_launch
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $node (@lnodes) {
|
for my $node (@lnodes) {
|
||||||
my $o = $ret{$node}->documentElement->getElementsByTagName("out");
|
my @o = $ret{$node}->documentElement->getElementsByTagName("out");
|
||||||
if ($o) {
|
if (@o) {
|
||||||
$output .= $o[0]->firstChild->nodeValue;
|
$output .= $o[0]->firstChild->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$e = $ret{$node}->documentElement->getElementsByTagName("err");
|
my @e = $ret{$node}->documentElement->getElementsByTagName("err");
|
||||||
if ($e) {
|
if (@e) {
|
||||||
$output .= $e[0]->firstChild->nodeValue;
|
$output .= $e[0]->firstChild->nodeValue;
|
||||||
}
|
}
|
||||||
$output .= $e[0]->firstChild->nodeValue;
|
$output .= $e[0]->firstChild->nodeValue;
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,18 @@ sub node_launch
|
||||||
$command->appendText($c->{nodeValue});
|
$command->appendText($c->{nodeValue});
|
||||||
$cmd->appendChild($command);
|
$cmd->appendChild($command);
|
||||||
|
|
||||||
my($wtr, $rdr, $stderr);
|
my($wtr, $rdr, $rv);
|
||||||
my $pid = open3($wtr, $rdr, $stderr, $c->{nodeValue});
|
my $stderr = "";
|
||||||
waitpid( $pid, 0 );
|
eval {
|
||||||
my $rv = $? >> 8;
|
my $pid = open3($wtr, $rdr, $stderr, "sh", "-c", $c->{nodeValue});
|
||||||
|
waitpid( $pid, 0 );
|
||||||
|
$rv = $? >> 8;
|
||||||
|
};
|
||||||
|
if ($@)
|
||||||
|
{
|
||||||
|
$stderr = $@ . $stderr;
|
||||||
|
$rv = -1;
|
||||||
|
}
|
||||||
|
|
||||||
my $out = $doc->createElement("out");
|
my $out = $doc->createElement("out");
|
||||||
my $str = "";
|
my $str = "";
|
||||||
|
|
@ -102,7 +110,7 @@ if ($#ARGV == 0)
|
||||||
{
|
{
|
||||||
log INFO, "Starting guantanamo.pl as node process";
|
log INFO, "Starting guantanamo.pl as node process";
|
||||||
|
|
||||||
Process::Client::launch("guantanamo", {"action" => "register", "nodename" => $ARGV[0]});
|
Process::Client::launch("guantanamo", {"action" => "register", "nodename" => $ARGV[0]}, undef, 1);
|
||||||
|
|
||||||
Process::register("guantanamo_".$ARGV[0], \&process_node);
|
Process::register("guantanamo_".$ARGV[0], \&process_node);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ sub cmd_account_alias($@)
|
||||||
return cmd_account_multiple_vieworchange('mailAlias', 'alias', @_);
|
return cmd_account_multiple_vieworchange('mailAlias', 'alias', @_);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub cmd_account_close($@)
|
sub cmd_account_close($;@)
|
||||||
{
|
{
|
||||||
my $login = shift;
|
my $login = shift;
|
||||||
|
|
||||||
|
|
@ -1572,6 +1572,8 @@ sub cmd_no_strong_auth_close(@)
|
||||||
|
|
||||||
say $entry->get_value("uid");
|
say $entry->get_value("uid");
|
||||||
|
|
||||||
|
cmd_account_close($entry->get_value("uid"));
|
||||||
|
|
||||||
my $body = "Bonjour ".decode('UTF-8', $entry->get_value("cn"), Encode::FB_CROAK).",
|
my $body = "Bonjour ".decode('UTF-8', $entry->get_value("cn"), Encode::FB_CROAK).",
|
||||||
|
|
||||||
Après plusieurs relances de notre part, vous n'avez toujours pas activé
|
Après plusieurs relances de notre part, vous n'avez toujours pas activé
|
||||||
|
|
|
||||||
Reference in a new issue