perfsonar-dev - perfsonar: r2171 - trunk/perfsonar-bundle
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: perfsonar: r2171 - trunk/perfsonar-bundle
- Date: Thu, 1 Mar 2007 11:02:41 -0500
Author: fernandes
Date: 2007-03-01 11:02:40 -0500 (Thu, 01 Mar 2007)
New Revision: 2171
Modified:
trunk/perfsonar-bundle/install.pl
Log:
Latest modifications to bundler install script, still not finished..
Modified: trunk/perfsonar-bundle/install.pl
===================================================================
--- trunk/perfsonar-bundle/install.pl 2007-03-01 15:22:46 UTC (rev 2170)
+++ trunk/perfsonar-bundle/install.pl 2007-03-01 16:02:40 UTC (rev 2171)
@@ -16,19 +16,29 @@
};
my $service;
+my $serviceDir;
my $returnCode;
my $answer;
my $installDir;
+my $webappsDir;
my @dirs;
-my %serviceMap = ( RRDMA() => "RRD-MA",
- SQLMA() => "SQL-MA",
+my %serviceDisplayMap = (
+ RRDMA() => "RRD MA",
+ SQLMA() => "SQL MA",
SSH() => "SSH/Telnet MP",
- CLMP() => "CL-MP"
+ CLMP() => "Command Line MP"
);
+my %serviceMap = (
+ RRDMA() => "RRD-MA",
+ SQLMA() => "SQL-MA",
+ SSH() => "TelnetSSHMP",
+ CLMP() => "CLMP"
+ );
+
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",
+ CLMP() =>
"http://www.gt-med.ufsc.br/docs/downloads/piPEs-BR/GFD/CLMP/perfSONAR-CLMP-1.0-RC4.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"
);
@@ -56,23 +66,238 @@
chomp($choice);
switch ($choice){
- case 1 { &newInstall(); }
- case 2 { &modifyMenu(); }
+ case 1 {
+ &serviceMenu();
+ &installDir();
+ print "\nContinuing with installation... \n";
+ &installTypeMenu();
+ }
+ case 2 {
+ &modifyMenu();
+ print "\nSetup complete. Continuing... \n";
+ &advanced();
+ }
case "" { exit; }
else { print "\nPlease type a valid number.\n"; }
}
+
+}
+
+sub modifyMenu() {
+ my $menu;
+ my $choice;
+ my $invalid = 1;
+ my $i;
+ my $serviceName;
+
+ &getWebapps();
+ &getServiceDir();
+
+ for my $key ( keys %serviceMap ) {
+ if ($serviceDir =~ /$serviceMap{$key}/){
+ $service = $key;
+ }
+ }
+
+ if ($service){
+ &installDir();
+ }else {
+ my $menu = "\nI couldn't detect the type of the service you want \n";
+ $menu .= "to modify. You'll need to do this manually: \n";
+ $menu .= "1. RRD-MA\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]: ";
+ while ($invalid){
+ print $menu;
+ $service = <STDIN>;
+ chomp($service);
+
+ if ($service == ""){
+ exit;
+ }
+
+ if (!($service =~ /^[1234]$/)){
+ print "\nPlease type a valid number.\n\n";
+ }else{
+ $invalid = 0;
+ }
+ }
+
+ &installDir();
+ }
}
-sub newInstall() {
+sub getServiceDir() {
my $menu;
my $choice;
my $invalid = 1;
my $i;
+ my $serviceName;
+
+ if (&detectExistingService()){
+ $menu = "\nI have detected the following services under the
directory \n";
+ $menu .= "$webappsDir:\n";
+
+ for ($i=0 ; $i < scalar(@dirs) ; $i++){
+ $serviceName = $dirs[$i];
+ $serviceName =~ s/\/WEB-INF//;
+ $serviceName =~ s/.*\///;
+ $dirs[$i] .= '/';
+ $menu .= ($i+1).". $serviceName\n";
+ }
+ $menu .= ($i+1).". Type the path to a different service.\n";
+ $menu .= "Please choose a number [enter exits]: ";
+ while ($invalid){
+ print $menu;
+
+ $choice = <STDIN>;
+ chomp($choice);
+
+ switch ($choice){
+ case [1..$i] {
+ $serviceDir = $dirs[$choice-1];
+ $invalid = 0;
+ }
+ case ($i+1) {
+ print "\nPlease type the path to the 'WEB-INF' directory
of \n";
+ print "the desired service: ";
+ $serviceDir = <STDIN>;
+ chomp($serviceDir);
+
+ if ($serviceDir =~ /WEB-INF$/){
+ $serviceDir .= '/';
+ }
+
+ if (system("test -d ".$serviceDir) != 0 || !($serviceDir
=~ /WEB-INF\/$/)){
+ print "\nDirectory $serviceDir doesn't seems to be a
valid directory.\n\n";
+ }else {
+ $invalid = 0;
+ }
+ }
+ case "" { exit; }
+ }
+ }
+ }else{
+ $menu .= "\nI haven't been able to detect existing services inside
\n";
+ $menu .= "the directory $webappsDir.\n";
+ $menu .= "Please type the path to the 'WEB-INF' directory of the \n";
+ $menu .= "service you want to modify [enter exits]:\n";
+ print $menu;
+ $serviceDir = <STDIN>;
+ chomp($serviceDir);
+
+ if (!($serviceDir =~ /\/$/)){
+ $serviceDir .= '/';
+ }
+
+ if (system("test -d ".$serviceDir) != 0){
+ print "\nDirectory $serviceDir doesn't seems to be a valid
directory.\n\n";
+ exit;
+ }
+ }
+}
+
+sub getWebapps() {
+ my $menu;
+ my $choice;
+ my $invalid = 1;
+ my $i;
- &serviceMenu();
-
- if (&detectExisting()){
+ if (&detectWebapps()){
+ $menu .= "\nI have detected the webapps directory at the following
\n";
+ if (scalar(@dirs) > 1) {
+ $menu .= "paths:\n";
+ for ($i=0 ; $i < scalar(@dirs) ; $i++){
+ $menu .= ($i+1).". Use ".$dirs[$i]."\n";
+ }
+ $menu .= ($i+1).". Type a different path for webapps
directory.\n";
+ $menu .= "Please choose a number [enter exits]: ";
+ while ($invalid){
+ print $menu;
+
+ $choice = <STDIN>;
+ chomp($choice);
+
+ switch ($choice){
+ case [1..$i] {
+ $webappsDir = $dirs[$choice-1];
+ $invalid = 0;
+ }
+ case ($i+1) {
+ print "\nPlease type the path to the webapps
directory: ";
+ $webappsDir = <STDIN>;
+ chomp($webappsDir);
+
+ if (system("test -d ".$webappsDir) != 0){
+ print "\nDirectory $webappsDir doesn't seems to
be a valid directory.\n\n";
+ }else {
+ $invalid = 0;
+ }
+ }
+ case "" { exit; }
+ else { print "\nPlease type a valid number.\n"; }
+ }
+ }
+ }
+ else {
+ $menu .= "path: $dirs[0]\n";
+ $menu .= "You can type now a different path or press enter to
\n";
+ $menu .= "accept the above directory: ";
+ print $menu;
+ $choice = <STDIN>;
+ chomp($choice);
+
+ $webappsDir = $dirs[0];
+ if ($choice != ''){
+ $webappsDir = $choice
+ }
+ if (system("test -d ".$webappsDir) != 0){
+ print "\nDirectory $webappsDir doesn't seems to be a valid
directory.\n\n";
+ exit;
+ }
+ }
+ }else{
+ $menu .= "\nI haven't been able to detect an existing webapps \n";
+ $menu .= "directory. Please type the location of your webapps \n";
+ $menu .= "directory now [enter exits]: ";
+ print $menu;
+ $choice = <STDIN>;
+ chomp($choice);
+
+ if ($choice != ''){
+ $webappsDir = $choice
+ }
+ if (system("test -d ".$webappsDir) != 0){
+ print "\nDirectory $webappsDir doesn't seems to be a valid
directory.\n\n";
+ exit;
+ }
+ }
+}
+
+sub detectExistingService(){
+ @dirs = `find $webappsDir -type d -regex ".*WEB-INF\$"`;
+ chomp(@dirs);
+ if (scalar(@dirs) > 0) { return 'true' }
+ else { return '' };
+}
+
+sub detectWebapps(){
+ @dirs = `find $currentDir -type d -regex ".*webapps\$" | grep -v
apache-tomcat`;
+ chomp(@dirs);
+ if (scalar(@dirs) > 0) { return 'true' }
+ else { return '' };
+}
+
+sub installDir() {
+ my $menu;
+ my $choice;
+ my $invalid = 1;
+ my $i;
+
+ if (&detectExistingInstall()){
$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";
@@ -84,10 +309,10 @@
$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";
+ $menu .= "2. Give the path to existing $serviceDisplayMap{$service}
installation files directory\n";
for ($i=0 ; $i < scalar(@dirs) ; $i++){
$dirs[$i] =~ s/\/ant/\//;
@@ -95,7 +320,7 @@
}
$menu .= "Please choose a number [enter to exit]: ";
$i = $i + 3;
-
+
while ($invalid){
print $menu;
@@ -105,38 +330,36 @@
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 .= '/';
- }
+ print "\nPlease type the path to service
$serviceDisplayMap{$service}'s installation files \n";
+ print "directory: ";
+ $installDir = <STDIN>;
+ chomp($installDir);
- if (!($installDir =~ /perfsonar\/$/)){
- $installDir .= 'perfsonar/';
- }
+ if (!($installDir =~ /\/$/)){
+ $installDir .= '/';
+ }
- 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;
- }
- }
+ 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;
- }
+ $installDir = $dirs[$choice-3];
+ $invalid = 0;
+ }
case "" { exit; }
else { print "\nPlease type a valid number.\n"; }
}
}
-
+
chomp($installDir);
- print "\nContinuing with installation...\n";
- &installTypeMenu();
}
sub download(){
@@ -144,10 +367,10 @@
my $choice;
my $file = $servicesTar{$service};
$file =~ s/.*\///;
-
- print "\nDownloading installation files for service
".$serviceMap{$service}.".\n";
+
+ print "\nDownloading installation files for service
".$serviceDisplayMap{$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";
@@ -157,7 +380,7 @@
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";
@@ -167,29 +390,29 @@
print $menu;
$choice = <STDIN>;
chomp($choice);
-
+
$installDir = "./";
if ($choice != ''){
- if (!($choice =~ /\/$/)){
- $choice = $choice . "/";
- }
- $installDir = $choice
+ if (!($choice =~ /\/$/)){
+ $choice = $choice . "/";
+ }
+ $installDir = $choice
}
-
- print "\nExtracting service $serviceMap{$service} installation
files...\n\n";
-
+
+ print "\nExtracting service $serviceDisplayMap{$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 = "\nWhich service would like to install?\n";
$menu .= "1. RRD-MA\n";
$menu .= "2. SQL-MA\n";
@@ -203,14 +426,14 @@
if ($service == ""){
exit;
}
-
+
if (!($service =~ /^[1234]$/)){
print "\nPlease type a valid number.\n\n";
&installationMenu;
}
}
-sub detectExisting(){
+sub detectExistingInstall(){
my $regex = "\".*$serviceMap{$service}.*/perfsonar/ant\$\"";
@dirs = `find $currentDir -type d -regex $regex`;
if (scalar(@dirs) > 0) { return 'true' }
@@ -236,10 +459,10 @@
}
sub basic(){
-
- print "\nStarting installation for service $serviceMap{$service}...\n";
+
+ print "\nStarting installation for service
$serviceDisplayMap{$service}...\n";
&action('pre-install');
-
+
if ($returnCode != 0){
&error();
if ($answer =~ /^y$/ or $answer =~ /^yes$/){
- perfsonar: r2171 - trunk/perfsonar-bundle, svnlog, 03/01/2007
Archive powered by MHonArc 2.6.16.