Commit 84d7e0b5 authored by bmortier's avatar bmortier

only putting gplv3 code here

parent 176f33f6
Argonaut AUTHORS
=======================
This is the alphabetical list of all people that have
contributed to the Argonaut project, beeing code, translations,
documentation and additional help.
* Benoit Mortier <benoit.mortier@opensides.be>
Butracking, QA
* Antoine Gallavardin <antoine.gallavardin@free.fr>
Quota original code
* Bernigaud Côme <come.bernigaud@laposte.net>
All the new deployment stuff :)
This diff is collapsed.
Argonaut changelog
==================
* Argonaut 0.9
First upstream release
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=fusiondirectory&url=https://github.com/fusiondirectory&title=FusionDirectory&language=en_GB&tags=github&category=software)
#######################################################################
#
# Argonaut::ClientDaemon -- Action to be done on clients
#
# Copyright (C) 2011-2013 FusionDirectory project <contact@fusiondirectory.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
#######################################################################
package Argonaut::ClientDaemon;
use strict;
use warnings;
use 5.008;
use Argonaut::Libraries::Common qw(:config);
my $base;
BEGIN {
$base = (USE_LEGACY_JSON_RPC ? "JSON::RPC::Legacy::Procedure" : "JSON::RPC::Procedure");
}
use base $base;
=item echo
return the parameters passed to it
=cut
sub echo : Public {
my ($s, $args) = @_;
$main::log->notice("echo method called with args $args");
return $args;
}
package
Argonaut::ClientDaemon::system;
=item describe
should be the answer of the system.describe standard JSONRPC call. It seems broken.
=cut
sub describe {
return {
sdversion => "1.0",
name => 'Argonaut::ClientDaemon',
};
}
1;
__END__
#######################################################################
#
# Argonaut::ClientDaemon::Modules::Service -- Service management
#
# Copyright (C) 2012-2013 FusionDirectory project <contact@fusiondirectory.org>
#
# Author: Côme BERNIGAUD
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
#######################################################################
package Argonaut::ClientDaemon::Modules::Service;
use strict;
use warnings;
use 5.008;
use Argonaut::Libraries::Common qw(:ldap :config);
my $base;
BEGIN {
$base = (USE_LEGACY_JSON_RPC ? "JSON::RPC::Legacy::Procedure" : "JSON::RPC::Procedure");
}
use base $base;
=item getServiceName
Returns the local name of a service
=cut
sub getServiceName : Private {
my ($nameFD) = @_;
my ($ldap,$ldap_base) = argonaut_ldap_handle($main::config);
my $mesg = $ldap->search( # perform a search
base => $ldap_base,
filter => "(&(objectClass=argonautClient)(ipHostNumber=".$main::client_settings->{'ip'}."))",
attrs => [ 'argonautServiceName' ]
);
if (scalar($mesg->entries)==1) {
foreach my $service (($mesg->entries)[0]->get_value("argonautServiceName")) {
my ($name,$value) = split(':',$service);
return $value if ($name eq $nameFD);
}
}
die "Service not found";
}
=item manage
execute an action on a service
return a string that begins with "done" if it worked.
=cut
sub manage : Public {
my ($s, $args) = @_;
my ($service,$action) = @{$args};
my $folder = getServiceName("folder");
my $exec = getServiceName($service);
$main::log->notice("manage service called: $service ($folder/$exec) $action");
system ("$folder/$exec $action\n") == 0 or die "$folder/$exec $action returned error $?";;
return "done : $action $exec";
}
=item is_running
returns "yes" or "no" wether if a service is running or not
=cut
sub is_running : Public {
my ($s, $args) = @_;
my ($service) = @{$args};
my $folder = getServiceName("folder");
my $exec = getServiceName($service);
$main::log->notice("is_running service called: $service ($folder/$exec) status");
my $lsb_code = system ("$folder/$exec status\n");
if ($lsb_code == 0) {
return "yes";
} else {
return "no";
}
}
1;
__END__
#######################################################################
#
# Argonaut::ClientDaemon::Modules::System -- System management
#
# Copyright (C) 2012-2013 FusionDirectory project <contact@fusiondirectory.org>
#
# Author: Côme BERNIGAUD
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
#######################################################################
package Argonaut::ClientDaemon::Modules::System;
use strict;
use warnings;
use 5.008;
use Argonaut::Libraries::Common qw(:ldap :config);
my $base;
BEGIN {
$base = (USE_LEGACY_JSON_RPC ? "JSON::RPC::Legacy::Procedure" : "JSON::RPC::Procedure");
}
use base $base;
=item halt
shutdown the computer
=cut
sub halt : Public {
my ($s, $args) = @_;
$main::log->notice("halt called");
system("sleep 5 && halt &");
return "shuting down";
}
=item reboot
reboot the computer
=cut
sub reboot : Public {
my ($s, $args) = @_;
$main::log->notice("reboot called, rebooting…");
system("sleep 5 && reboot &");
return "rebooting";
}
1;
__END__
#!/usr/bin/perl
#######################################################################
#
# argonaut-client-management
#
# Copyright (C) 2011-2014 FusionDirectory project <contact@fusiondirectory.org>
#
# Author: Côme BERNIGAUD
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
#######################################################################
use strict;
use warnings;
use 5.008;
use Argonaut::Libraries::Common qw(:ldap :config :file);
use if (USE_LEGACY_JSON_RPC), 'JSON::RPC::Legacy::Server::Daemon';
use if not (USE_LEGACY_JSON_RPC), 'JSON::RPC::Server::Daemon';
use Log::Handler;
use App::Daemon qw(daemonize);
# where to look for modules files
use Module::Pluggable search_path => 'Argonaut::ClientDaemon::Modules', sub_name => 'modules';
our ($config, $client_settings, $server_settings);
my $logfile = "argonaut-client.log";
my $piddir = "/var/run/argonaut";
my $pidfile = "argonaut-client.pid";
$SIG{TERM}=\&sig_term_handler;
$SIG{INT}=\&sig_int_handler;
readConfig();
argonaut_create_dir($client_settings->{'logdir'});
our $log = Log::Handler->create_logger("argonaut-client-management");
$log->add(
file => {
filename => $client_settings->{'logdir'}."/$logfile",
maxlevel => "debug",
minlevel => "emergency",
newline => 1,
}
);
argonaut_create_dir($piddir);
$App::Daemon::pidfile = "$piddir/$pidfile";
$App::Daemon::logfile = $client_settings->{'logdir'}."/$logfile";
$App::Daemon::as_user = "root";
daemonize();
my $serverClass;
if (USE_LEGACY_JSON_RPC) {
$serverClass = "JSON::RPC::Legacy::Server::Daemon";
} else {
$serverClass = "JSON::RPC::Server::Daemon";
}
my $server = $serverClass->new(
LocalPort => $client_settings->{'port'},
($server_settings->{'protocol'} eq 'https') ? (SSL_server => 1,
SSL_key_file => $client_settings->{'keyfile'},
SSL_cert_file => $client_settings->{'certfile'},)
: ());
$log->notice("argonaut-client-management started on port ".$client_settings->{'port'});
$server->version(0);
$server->return_die_message(1);
my $modules = import_modules();
$server->dispatch_to($modules)->handle();
sub readConfig {
$config = argonaut_read_config;
$server_settings = argonaut_get_server_settings($config,$config->{'server_ip'});
$client_settings = argonaut_get_client_settings($config,$config->{'client_ip'});
}
sub import_modules {
foreach my $module (modules()) {
$log->notice("Loaded module $module");
}
return ['Argonaut::ClientDaemon',modules()];
}
sub sig_int_handler {
$log->notice("argonaut-client-management on port ".$client_settings->{'port'}." terminated by sigint");
exit(0);
}
sub sig_term_handler {
$log->notice("argonaut-client-management on port ".$client_settings->{'port'}." terminated by sigterm");
exit(0);
}
__END__
=head1 NAME
argonaut-client - running actions given by the argonaut server
=head1 SYNOPSIS
argonaut-client
=head1 DESCRIPTION
argonaut-client is getting actions from argonaut server and run them. It is modular
and can load various modules at run time.
=head1 BUGS
Please report any bugs, or post any suggestions, to the fusiondirectory mailing list fusiondirectory-users or to
<https://forge.fusiondirectory.org/projects/argonaut-agents/issues/new>
=head1 LICENCE AND COPYRIGHT
This code is part of FusionDirectory <http://www.fusiondirectory.org>
=over 1
=item Copyright (C) 2011-2014 FusionDirectory project
=back
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
=cut
.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "ARGONAUT-CLIENT 1"
.TH ARGONAUT-CLIENT 1 "2014-06-24" "Argonaut 0.9.1" "Argonaut Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
argonaut\-client \- running actions given by the argonaut server
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
argonaut-client
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
argonaut-client is getting actions from argonaut server and run them. It is modular
and can load various modules at run time.
.SH "BUGS"
.IX Header "BUGS"
Please report any bugs, or post any suggestions, to the fusiondirectory mailing list fusiondirectory-users or to
<https://forge.fusiondirectory.org/projects/argonaut\-agents/issues/new>
.SH "LICENCE AND COPYRIGHT"
.IX Header "LICENCE AND COPYRIGHT"
This code is part of FusionDirectory <http://www.fusiondirectory.org>
.IP "Copyright (C) 2011\-2014 FusionDirectory project" 1
.IX Item "Copyright (C) 2011-2014 FusionDirectory project"
.PP
This program is distributed in the hope that it will be useful,
but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of
\&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the
\&\s-1GNU\s0 General Public License for more details.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package XML::SAX::RPMHandler;
use base qw(XML::SAX::Base);
sub new {
my $type = shift;
$self = {
'packages' => shift,
'package' => undef,
'key' => undef,
'fields' => shift,
'regexps' => shift,
'from' => shift,
'to' => shift,
'indice' => shift || 0,
};
return bless $self, $type;
}
sub start_document {
my ($self, $doc) = @_;
$self->{package} = undef;
$self->{key} = undef;
}
sub start_element {
my ($self, $el) = @_;
if ($el->{LocalName} eq 'package') {
$self->{package} = {};
$self->{key} = undef;
} elsif ((defined $self->{package}) && (defined $self->{fields}->{$el->{LocalName}})) {
$self->{key} = $el->{LocalName};
$self->{attrs} = $el->{Attributes};
$self->{data} = '';
}
}
sub characters {
my ($self, $data) = @_;
if ((defined $self->{package}) && (defined $self->{key})) {
if ($self->{key} eq 'name') {
if ((ref($self->{packages}) eq 'HASH') && (defined $self->{packages}->{$data->{Data}})) {
$self->{package} = undef;
return;
}
if (defined $self->{regexps}) {
my $match = 0;
foreach my $regexp (@{$self->{regexps}}) {
if ($data->{Data} =~ /$regexp/) {
$match = 1;
last;
}
}
if($match == 0) {
$self->{package} = undef;
return;
}
}
}
$self->{data} .= $data->{Data};
}
}
sub end_element {
my ($self, $el) = @_;
if (defined $self->{package}) {
if ($el->{LocalName} eq 'package') {
if (ref($self->{packages}) eq 'ARRAY') {
push @{$self->{packages}}, $self->{package};
} elsif (ref($self->{packages}) eq 'HASH') {
$self->{packages}->{$self->{package}->{$self->{fields}->{'name'}}} = $self->{package};
}
$self->{package} = undef;
$self->{indice}++;
if ((defined $self->{to}) && ($self->{indice} >= $self->{to})) {
die 'LIMIT_REACHED';
}
} elsif (defined $self->{fields}->{$el->{LocalName}}) {
if (ref($self->{fields}->{$el->{LocalName}}) eq 'CODE') {
$self->{fields}->{$el->{LocalName}}($self->{package}, $self->{key}, $self->{data}, $self->{attrs});
} else {
$self->{package}->{$self->{fields}->{$el->{LocalName}}} = $self->{data};
}
$self->{key} = undef;
}
}
}
1;
=pod
Example:
my $packages = [];
my $parser = XML::SAX::ParserFactory->parser(
Handler => XML::SAX::RPMHandler->new(
$packages,
{
'name' => 'PACKAGE',
'description' => sub {
my ($package, undef, $data) = @_;
$package->{'DESCRIPTION'} = $data;
},
'version' => sub {
my ($package, undef, $data, $attrs) = @_;
$package->{'VERSION'} = $attrs->{'{}ver'}->{'Value'}.'-'.$attrs->{'{}rel'}->{'Value'};
},
},
[
'^kernel',
],
)
);
$parser->parse_uri("Centos/6/os/x86_64/primary.xml");
=cut
package XML::SAX::RPMRepomdHandler;
use base qw(XML::SAX::Base);
sub new {
my $class = shift;
$self = {
'type' => shift || 'primary',
};
return bless $self, $class;
}
sub start_document {
my ($self, $doc) = @_;