summaryrefslogtreecommitdiffstats
path: root/mgaonline_agent.pl
diff options
context:
space:
mode:
authorMageia SVN-Git Migration <svn-git-migration@mageia.org>2011-05-14 01:22:07 +0100
committerMageia SVN-Git Migration <svn-git-migration@mageia.org>2011-05-14 01:22:07 +0100
commite0ada251ac68dc91192c7ec7d10f3a1d7784916a (patch)
tree225ed465e93c82ad37c2794144850635b395d594 /mgaonline_agent.pl
parent5d4a18c95ac1ef5a657b5dcefd8a47e429d74058 (diff)
downloadmgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar.gz
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar.bz2
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.tar.xz
mgaonline-e0ada251ac68dc91192c7ec7d10f3a1d7784916a.zip
Synthesized commit during git-svn import combining previous Mandriva history with Mageia.2.77.22
This commit consitsts of the following subversion commits: ------------------------------------------------------------------------ r1310 | dmorgan | 2011-05-14 01:22:07 +0100 (Sat, 14 May 2011) | 1 line Import cleaned mgaonline ------------------------------------------------------------------------
Diffstat (limited to 'mgaonline_agent.pl')
-rwxr-xr-xmgaonline_agent.pl78
1 files changed, 78 insertions, 0 deletions
diff --git a/mgaonline_agent.pl b/mgaonline_agent.pl
new file mode 100755
index 00000000..bd687a36
--- /dev/null
+++ b/mgaonline_agent.pl
@@ -0,0 +1,78 @@
+#!/usr/bin/perl -w
+################################################################################
+# mdvonline_agent #
+# #
+# Copyright (C) 2005 Mandriva #
+# #
+# Romain d'Alverny <rdalverny at mandriva dot com> #
+# #
+# This program is free software; you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License Version 2 as #
+# published by the Free Software Foundation. #
+# #
+# 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, write to the Free Software #
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+################################################################################
+
+# $Id$
+
+use strict;
+use POSIX;
+use lib qw(/usr/lib/libDrakX /usr/lib/libDrakX/drakfirsttime);
+use common;
+use mgaonline;
+use Switch;
+use Data::Dumper;
+use Error qw(:try);
+
+# DNS service discovery
+use Discover;
+
+# logging
+use Log::Agent;
+require Log::Agent::Driver::File; # logging made to file
+logconfig(
+ '-driver' => Log::Agent::Driver::File->make(
+ '-prefix' => $0,
+ '-showpid' => 1,
+ '-file' => 'mdvonline.log',
+ ),
+ #-caller => [ -display => '($sub/$line)', -postfix => 1 ],
+ '-priority' => [ '-display' => '[$priority]' ],
+);
+
+logsay "==================";
+mgaonline::is_running('mdvonline_agent') and die "mdvonline_agent already running\n";
+require_root_capability();
+
+my %conf = mgaonline::get_configuration();
+print Dumper(%conf);
+
+! defined %conf and logwarn "no configuration set", exit 0;
+
+logsay "checking for tasks";
+print Dumper(%conf);
+my $answer = mgaonline::soap_get_task($conf{HOST_ID}, $conf{HOST_KEY});
+
+print Dumper($answer);
+
+if ($answer->{code} == 0) {
+ if ($answer->{data}{command} eq 'none') {
+ logsay "nothing to do";
+ }
+ else {
+ logsay "got something";
+ mgaonline::run_and_return_task($answer->{data});
+ }
+ exit 1;
+}
+else {
+ logwarn "something went wrong " . $answer->{message} . " (" . $answer->{code} . ")";
+ exit 0;
+}