diff options
author | Romain d'Alverny <rdalverny@mandriva.org> | 2005-12-06 19:10:34 +0000 |
---|---|---|
committer | Romain d'Alverny <rdalverny@mandriva.org> | 2005-12-06 19:10:34 +0000 |
commit | 87c4b0b438efa3cfe46898fcb6a5b7942dae752e (patch) | |
tree | 1daae4d2f4f33bc1f7db6ef2697f1c99fee8b04e | |
parent | 59e6a5267eb3c86b6f67b6aca8e675f367f447cb (diff) | |
download | mgaonline-87c4b0b438efa3cfe46898fcb6a5b7942dae752e.tar mgaonline-87c4b0b438efa3cfe46898fcb6a5b7942dae752e.tar.gz mgaonline-87c4b0b438efa3cfe46898fcb6a5b7942dae752e.tar.bz2 mgaonline-87c4b0b438efa3cfe46898fcb6a5b7942dae752e.tar.xz mgaonline-87c4b0b438efa3cfe46898fcb6a5b7942dae752e.zip |
Online agent draft for service recovery (v2 to v3) and dns discovery.
-rw-r--r-- | mdvonline_agent.pl | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/mdvonline_agent.pl b/mdvonline_agent.pl new file mode 100644 index 00000000..04709444 --- /dev/null +++ b/mdvonline_agent.pl @@ -0,0 +1,109 @@ +#!/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 mdkonline; +use Data::Dumper; + +# 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]' ], +); + +# TODO set this in mdkonline.pm ? +my $conffile = '/etc/sysconfig/mdkonline'; +my $service = 'https://localhost/~romain/online3/htdocs/service'; + +# script starts here +mdkonline::is_running('mdvonline_agent') + and die "mdvonline_agent already running\n"; + +#require_root_capability(); + +my %conf; +my $ret = 0; + +# 1. check configuration (local) or set from dns if any +if( ( -e $conffile ) && ( -s $conffile ) ) { + %conf = getVarsFromSh($conffile); + + if( defined $conf{MACHINE} && ! defined $conf{VERSION} ) { #|| $conf{VERSION} lt 3 ) { + logsay "old configuration detected: trying to migrate to new scheme"; + $ret = mdkonline::upgrade_to_v3(); + if( $ret eq 1 ) { logsay "succeeded"; } + else { logsay "failed"; } + } + else { + if( defined $conf{MOBILE} && $conf{MOBILE} eq 'TRUE' ) { + # TODO check dns service for a specific update server + # if there is one, it may supersedes default conf update server + # or the one provided by the Online server? + } + $ret = 1; + } +} +else { + logsay "no configuration file found"; + logsay "starting dns service discovery"; + my $sd = new Discover; + my $serviceinfo = $sd->search(); + if ( $serviceinfo ) { + logsay "found service with info"; + print Dumper($serviceinfo); + # TODO check service certificate + # TODO register to service + # TODO set config file + $ret = 0; + } + else { + #print Dumper($sd); + logsay "no service found"; + $ret = 0; + } + $ret = 0; +} + +if( $ret eq 1 ) { + # 2. now check and run task + print "checking for somethign to do.\n"; + my $task = mdkonline::soap_get_task( $conf{HOST_ID}, $conf{HOST_KEY} ); + print Dumper($task); +} + +logsay "done"; +$ret;
\ No newline at end of file |