Skip to Content.
Sympa Menu

perfsonar-dev - r2127 - trunk/perfsonar-bundle

Subject: perfsonar development work

List archive

r2127 - trunk/perfsonar-bundle


Chronological Thread 
  • From:
  • To:
  • Subject: r2127 - trunk/perfsonar-bundle
  • Date: Thu, 22 Feb 2007 11:25:51 -0500

Author: fernandes
Date: 2007-02-22 11:25:49 -0500 (Thu, 22 Feb 2007)
New Revision: 2127

Modified:
trunk/perfsonar-bundle/install.pl
Log:
Incomplete, but functional, bundle installation script.
Be free to test it. Any feedback is welcome.



Modified: trunk/perfsonar-bundle/install.pl
===================================================================
--- trunk/perfsonar-bundle/install.pl 2007-02-22 13:52:54 UTC (rev 2126)
+++ trunk/perfsonar-bundle/install.pl 2007-02-22 16:25:49 UTC (rev 2127)
@@ -8,65 +8,236 @@
use Switch;
use strict;

+use constant {
+ RRDMA => 1,
+ SQLMA => 2,
+ SSH => 3,
+ CLMP => 4
+};
+
my $service;
-my $installType;
my $returnCode;
my $answer;
+my $installDir;
+my @dirs;

+my %serviceMap = ( RRDMA() => "RRD-MA",
+ SQLMA() => "SQL-MA",
+ SSH() => "SSH/Telnet MP",
+ CLMP() => "CL-MP"
+ );
+
+my %servicesTar = ( RRDMA() =>
"ahttp://monstera.man.poznan.pl/jra1-wiki/images/files/perfSONAR-RRD-MA-2.0-RC5.tar.gz";,
+ CLMP() =>
"http://www.gt-med.ufsc.br/docs/downloads/piPEs-BR/GFD/CLMP/perfSONAR-CLMP-1.0-RC3.tar.gz";,
+ SSH() =>
"http://downloads.geant2.net/repository/perfSONAR/micro-releases/MPTelnetSSH-0.7.tar.gz";,
+ SQLMA() =>
"http://downloads.geant2.net/repository/perfSONAR/micro-releases/perfSONAR-SQL-MA-1.0-RC3.tar.gz";
+ );
+
+my $currentDir = `pwd`;
+chomp($currentDir);
+$currentDir .= "/";
+
while('true'){

+ &introMenu();
+
+}
+
+
+sub introMenu(){
+
+ my $menu = "Welcome to the perfSONAR services installer.\n\n";
+ $menu .= "What would you like to do?\n";
+ $menu .= "1. Install a new service\n";
+ $menu .= "2. Modify or test an existing installation\n";
+ $menu .= "Please choose a number [enter to exit]: ";
+ print $menu;
+ my $choice = <STDIN>;
+ chomp($choice);
+
+ switch ($choice){
+ case 1 { &newInstall(); }
+ case 2 { &modifyMenu(); }
+ case "" { exit; }
+ else { print "\nPlease type a valid number.\n"; }
+ }
+
+}
+
+sub newInstall() {
+ my $menu;
+ my $choice;
+ my $invalid = 1;
+ my $i;
+
&serviceMenu();
+
+ if (&detectExisting()){
+ $menu .= "\nI have detected that there might be directories which
\n";
+ $menu .= "already have the installation files for this service. \n";
+ $menu .= "You can choose to use one of these, point to another \n";
+ $menu .= "directory, or download the installation files again: \n\n";
+ }else{
+ $menu .= "\nI haven't been able to detect an existing directory \n";
+ $menu .= "with the installation files for this service. If you \n";
+ $menu .= "have already downloaded and extracted these files, you \n";
+ $menu .= "can choose to give the directory location. Otherwise, \n";
+ $menu .= "choose to download the installation files. \n\n";
+ }
+
+ $menu .= "What do you want to do?\n";
+ $menu .= "1. Download installation files\n";
+ $menu .= "2. Give the path to existing $serviceMap{$service}
installation files directory\n";
+
+ for ($i=0 ; $i < scalar(@dirs) ; $i++){
+ $dirs[$i] =~ s/\/ant/\//;
+ $menu .= ($i+3).". Use ".$dirs[$i]."\n";
+ }
+ $menu .= "Please choose a number [enter to exit]: ";
+ $i = $i + 3;
+
+ while ($invalid){
+ print $menu;
+
+ $choice = <STDIN>;
+ chomp($choice);
+
+ switch ($choice){
+ case 1 { $invalid = &download(); }
+ case 2 {
+ print "\nPlease type the path to service
$serviceMap{$service}'s installation files \n";
+ print "directory: ";
+ $installDir = <STDIN>;
+ chomp($installDir);
+
+ if (!($installDir =~ /\/$/)){
+ $installDir .= '/';
+ }
+
+ if (!($installDir =~ /perfsonar\/$/)){
+ $installDir .= 'perfsonar/';
+ }
+
+ if (system("test -f
".$installDir."ant/build.xml") != 0){
+ print "\nDirectory $installDir doesn't seems
to be a valid directory.\n\n";
+ }else {
+ $invalid = 0;
+ }
+ }
+ case [3..$i] {
+ $installDir = $dirs[$choice-3];
+ $invalid = 0;
+ }
+ case "" { exit; }
+ else { print "\nPlease type a valid number.\n"; }
+ }
+ }
+
+ chomp($installDir);
+ print "\nContinuing with installation...\n";
+
&installTypeMenu();
+}

- if ($installType == "1"){
- &basic();
- }else{
- &advanced();
+sub download(){
+ my $menu;
+ my $choice;
+ my $file = $servicesTar{$service};
+ $file =~ s/.*\///;
+
+ print "\nDownloading installation files for service
".$serviceMap{$service}.".\n";
+ print "This might take a while depending on your connection
speed...\n\n";
+
+ if (system("wget $servicesTar{$service}") != 0){
+ my $notice = "\nThere seems to be a problem downloading the
installation files from \n";
+ $notice .= "$servicesTar{$service}. \n";
+ $notice .= "Please try to download this file manually and put it in
my directory \n";
+ $notice .= "($currentDir). \n";
+ $notice .= "Press any key when you have finished or CTRL+C to
exit...\n";
+ print $notice;
+ <STDIN>;
}
+
+ `test -s $file` == 0 or die "FATAL: file $file is not present.";

+ $menu = "\nI'll now untar the installation files directory into my
current \n";
+ $menu .= "directory ($currentDir). \n";
+ $menu .= "If you would like to extract the files to another directory,
please \n";
+ $menu .= "type it now or else just press enter to accept the above
directory.\n";
+ print $menu;
+ $choice = <STDIN>;
+ chomp($choice);
+
+ $installDir = "./";
+ if ($choice != ''){
+ if (!($choice =~ /\/$/)){
+ $choice = $choice . "/";
+ }
+ $installDir = $choice
+ }
+
+ print "\nExtracting service $serviceMap{$service} installation
files...\n\n";
+
+ if (system("tar -zxvf $file -C $installDir") != 0){
+ print "error";
+ }
+
+ $file =~ s/\.tar.*//;
+ $installDir .= $file.'/perfsonar/';
+
+ return 0;
}

sub serviceMenu(){

- my $menu = "Which service would like to install?\n";
+ my $menu = "\nWhich service would like to install?\n";
$menu .= "1. RRD-MA\n";
- $menu .= "2. CLMP\n";
+ $menu .= "2. SQL-MA\n";
+ $menu .= "3. SSH/Telnet MP\n";
+ $menu .= "4. Commande Line MP\n";
$menu .= "Please choose a number [enter to exit]: ";
print $menu;
$service = <STDIN>;
-
+ chomp($service);
+
if ($service == ""){
exit;
}

- if (!($service =~ /^[12]$/)){
+ if (!($service =~ /^[1234]$/)){
print "\nPlease type a valid number.\n\n";
&installationMenu;
}
}

+sub detectExisting(){
+ my $regex = "\".*$serviceMap{$service}.*/perfsonar/ant\$\"";
+ @dirs = `find $currentDir -type d -regex $regex`;
+ if (scalar(@dirs) > 0) { return 'true' }
+ else { return '' };
+}
+
sub installTypeMenu(){
-
my $menu = "\nWhich installation type do you want?\n";
$menu .= "1. Basic\n";
$menu .= "2. Advanced\n";
- $menu .= "Please choose a number [Basic]: ";
+ $menu .= "Please choose a number [enter to exit]: ";
+
print $menu;
- $installType = <STDIN>;
-
- if ($installType == ""){
- $installType = 1;
+ my $choice = <STDIN>;
+ chomp($choice);
+
+ switch ($choice){
+ case 1 { &basic(); }
+ case 2 { &advanced(); }
+ case "" { exit; }
+ else { print "\nPlease type a valid number.\n";
&installTypeMenu(); }
}
-
- if (!($installType =~ /^[12]$/)){
- print "\nPlease type a valid number.\n\n";
- &installTypeMenu;
- }
-
}

sub basic(){
-
+
+ print "\nStarting installation for service $serviceMap{$service}...\n";
&action('pre-install');

if ($returnCode != 0){
@@ -120,7 +291,7 @@
sub error(){
my $menu = "\n\nIt seems an error occurred in one of the installation
steps.\n";
$menu .= "Would you like to try that step again?\n";
- $menu .= "(y[es] to try, anything else goes back to the installation
menu): ";
+ $menu .= "(yes [y] or [yes] to try, anything else goes back to the
installation menu): ";
print $menu;
$answer = <STDIN>;
}
@@ -159,8 +330,5 @@

sub action(){
my $target = shift(@_);
- switch ($service){
- case 1 { $returnCode = system "ant -q -f build-rrdma.xml " .
$target; }
- case 2 { $returnCode = system "ant -q -f build-clmp.xml " .
$target; }
- }
+ $returnCode = system "ant -q -f " . $installDir . "ant/build.xml " .
$target;
}



  • r2127 - trunk/perfsonar-bundle, svnlog, 02/22/2007

Archive powered by MHonArc 2.6.16.

Top of Page