Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2466 - trunk/perfsonar-bundle

Subject: perfsonar development work

List archive

perfsonar: r2466 - trunk/perfsonar-bundle


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2466 - trunk/perfsonar-bundle
  • Date: Thu, 7 Jun 2007 13:34:45 -0400

Author: fernandes
Date: 2007-06-07 13:34:44 -0400 (Thu, 07 Jun 2007)
New Revision: 2466

Modified:
trunk/perfsonar-bundle/install.pl
Log:
Changed all switch blocks to if/elsif because of Switch.pm problems and to
have less strict requirements to run the installer.



Modified: trunk/perfsonar-bundle/install.pl
===================================================================
--- trunk/perfsonar-bundle/install.pl 2007-06-07 16:20:58 UTC (rev 2465)
+++ trunk/perfsonar-bundle/install.pl 2007-06-07 17:34:44 UTC (rev 2466)
@@ -5,21 +5,22 @@

package perfsonar;

-use Switch;
use strict;
use LWP::UserAgent;
-my $ua = LWP::UserAgent->new;
-my $req = HTTP::Request->new(POST =>
'http://mu.dante.org.uk:8092/Emailer/mailer.jsp');
+my $ua = LWP::UserAgent->new;
+my $req =
+ HTTP::Request->new(
+ POST => 'http://mu.dante.org.uk:8092/Emailer/mailer.jsp' );
$req->content_type('application/x-www-form-urlencoded');

use constant {
- RRDMA => 1,
- SQLMA => 2,
- SSH => 3,
- CLMP => 4,
- LS => 5,
- BWCTL => 6,
- PERL => 6 #The number where perl services start
+ RRDMA => 1,
+ SQLMA => 2,
+ SSH => 3,
+ CLMP => 4,
+ LS => 5,
+ BWCTL => 6,
+ PERL => 6 #The number where perl services start
};

my $service;
@@ -30,857 +31,1007 @@
my $webappsDir;
my @dirs;
my $modification = '';
-my $isPerl = '';
-my $verbose = '';
+my $isPerl = '';
+my $verbose = '';

-my %serviceDisplayMap = (
- RRDMA() => "RRD MA",
- SQLMA() => "SQL MA",
- SSH() => "SSH/Telnet MP",
- CLMP() => "Command Line MP",
- LS() => "Lookup Service",
- BWCTL() => "BWCTL MP",
- );
+my %serviceDisplayMap = (
+ RRDMA() => "RRD MA",
+ SQLMA() => "SQL MA",
+ SSH() => "SSH/Telnet MP",
+ CLMP() => "Command Line MP",
+ LS() => "Lookup Service",
+ BWCTL() => "BWCTL MP",
+);

-my %serviceMap = (
- RRDMA() => "RRD",
- SQLMA() => "SQL",
- SSH() => "SSH",
- CLMP() => "CLMP",
- LS() => "LS",
- BWCTL() => "BWCTL",
- );
+my %serviceMap = (
+ RRDMA() => "RRD",
+ SQLMA() => "SQL",
+ SSH() => "SSH",
+ CLMP() => "CLMP",
+ LS() => "LS",
+ BWCTL() => "BWCTL",
+);

-my %servicesTar = (
- RRDMA() =>
"http://www.perfsonar.net/download/services/services_download.php?product=perfSONAR-RRD-MA&version=2.2";,
- CLMP() =>
"http://www.perfsonar.net/download/services/services_download.php?product=perfSONAR-CLMP&version=1.1";,
- SSH() =>
"http://www.perfsonar.net/download/services/services_download.php?product=JAVA-SSHTELNET-MP&version=1.1";,
- SQLMA() =>
"http://www.perfsonar.net/download/services/services_download.php?product=perfSONAR-SQL-MA&version=1.3";,
- LS() =>
"http://www.perfsonar.net/download/services/services_download.php?product=XML-LS&version=1.1.1";,
- BWCTL() =>
"http://www.perfsonar.net/download/services/services_download.php?product=DFN_Perl-Base_BWCTL-MP&version=0.2";,
- );
-
-my %serviceFilesTar = (
- RRDMA() => "perfSONAR-RRD-MA-2.2.tar.gz",
- CLMP() => "perfSONAR-CLMP-1.1.tar.gz",
- SSH() => "JAVA-SSHTELNET-MP-1.1.tar.gz",
- SQLMA() => "perfSONAR-SQL-MA-1.3.tar.gz",
- LS() => "XML-LS-1.1.1.tar.gz",
- BWCTL() => "DFN_Perl-Base_BWCTL-MP-0.2.tar.gz",
- );
+my %servicesTar = (
+ RRDMA() =>
+"http://www.perfsonar.net/download/services/services_download.php?product=perfSONAR-RRD-MA&version=2.2";,
+ CLMP() =>
+"http://www.perfsonar.net/download/services/services_download.php?product=perfSONAR-CLMP&version=1.1";,
+ SSH() =>
+"http://www.perfsonar.net/download/services/services_download.php?product=JAVA-SSHTELNET-MP&version=1.1";,
+ SQLMA() =>
+"http://www.perfsonar.net/download/services/services_download.php?product=perfSONAR-SQL-MA&version=1.3";,
+ LS() =>
+"http://www.perfsonar.net/download/services/services_download.php?product=XML-LS&version=1.1.1";,
+ BWCTL() =>
+"http://www.perfsonar.net/download/services/services_download.php?product=DFN_Perl-Base_BWCTL-MP&version=0.2";,
+);

+my %serviceFilesTar = (
+ RRDMA() => "perfSONAR-RRD-MA-2.2.tar.gz",
+ CLMP() => "perfSONAR-CLMP-1.1.tar.gz",
+ SSH() => "JAVA-SSHTELNET-MP-1.1.tar.gz",
+ SQLMA() => "perfSONAR-SQL-MA-1.3.tar.gz",
+ LS() => "XML-LS-1.1.1.tar.gz",
+ BWCTL() => "DFN_Perl-Base_BWCTL-MP-0.2.tar.gz",
+);
+
my $currentDir = `pwd`;
chomp($currentDir);
$currentDir .= "/";

-while('true'){
+while ('true') {

- &introMenu();
+ &introMenu();

}

+sub 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 .= "3. Give feedback to the perfSONAR team\n";
+ $menu .= "Please choose a number [enter to exit]: ";
+ print $menu;
+ my $choice = <STDIN>;
+ chomp($choice);

- 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 .= "3. Give feedback to the perfSONAR team\n";
- $menu .= "Please choose a number [enter to exit]: ";
- print $menu;
- my $choice = <STDIN>;
- chomp($choice);
+ if ( $choice eq 1 ) {
+ print "\nWhich service would like to install?\n";
+ &serviceMenu();
+ &installDir();
+ print "\nContinuing with installation... \n";
+ &installTypeMenu();
+ }
+ elsif ( $choice eq 2 ) {
+ $modification = '1';
+ &modifyMenu();
+ &getProperties();
+ print "\nSetup complete. Continuing... \n";
+ &advanced();
+ }
+ elsif ( $choice eq 3 ) {
+ &getFeedback();
+ }
+ elsif ( $choice eq "" ) {
+ exit;
+ }
+ else {
+ print "\nPlease type a valid number.\n";
+ }

- switch ($choice){
- case 1 {
- print "\nWhich service would like to install?\n";
- &serviceMenu();
- &installDir();
- print "\nContinuing with installation... \n";
- &installTypeMenu();
- }
- case 2 {
- $modification = '1';
- &modifyMenu();
- &getProperties();
- print "\nSetup complete. Continuing... \n";
- &advanced();
- }
- case 3 {
- &getFeedback();
- }
- case "" { exit; }
- else { print "\nPlease type a valid number.\n"; }
- }
-
}

-sub getFeedback(){
- my $menu;
- my $stop = '';
- my $message;
- my $name;
- my $email;
- my $org;
- my $tmp;
+sub getFeedback() {
+ my $menu;
+ my $stop = '';
+ my $message;
+ my $name;
+ my $email;
+ my $org;
+ my $tmp;

- $menu = "\nBe free to write any complaints, suggestions or comments, any
type \n";
- $menu .= "of feedback is appreciated. Your feedback will be sent to
perfSONAR's \n";
- $menu .= "<XXX> mailing list. You'll be asked to give some personal
information \n";
- $menu .= "first, it is completely optional (you can just press enter to
ignore): \n";
- $menu .= "\nYour name: ";
- print $menu;
- $name = <STDIN>;
- chomp($name);
+ $menu =
+ "\nBe free to write any complaints, suggestions or comments, any
type \n";
+ $menu .=
+"of feedback is appreciated. Your feedback will be sent to perfSONAR's \n";
+ $menu .=
+"<XXX> mailing list. You'll be asked to give some personal information \n";
+ $menu .=
+"first, it is completely optional (you can just press enter to ignore): \n";
+ $menu .= "\nYour name: ";
+ print $menu;
+ $name = <STDIN>;
+ chomp($name);

- print "Email: ";
- $email = <STDIN>;
- chomp($email);
+ print "Email: ";
+ $email = <STDIN>;
+ chomp($email);

- print "Organization: ";
- $org = <STDIN>;
- chomp($org);
+ print "Organization: ";
+ $org = <STDIN>;
+ chomp($org);

- $message = "Name: $name\n"."Email: $email\n"."Organization: $org\n\n";
+ $message = "Name: $name\n" . "Email: $email\n" . "Organization:
$org\n\n";

- print "You can now type your message, write 'STOP' in a newline when you
have finished.\n";
- while (!$stop){
- $tmp = <STDIN>;
- chomp($tmp);
+ print
+"You can now type your message, write 'STOP' in a newline when you have
finished.\n";
+ while ( !$stop ) {
+ $tmp = <STDIN>;
+ chomp($tmp);

- if ($tmp ne 'STOP'){
- $message .= $tmp."\n";
- }
- else{
- $stop = 'true';
- }
- }
+ if ( $tmp ne 'STOP' ) {
+ $message .= $tmp . "\n";
+ }
+ else {
+ $stop = 'true';
+ }
+ }

- print "\nSending your feedback...\n";
+ print "\nSending your feedback...\n";

- $req->content('message=12345='.$message);
- my $res = $ua->request($req);
+ $req->content( 'message=12345=' . $message );
+ my $res = $ua->request($req);

- if ($res->is_success && !($res->as_string =~ /NOT-OK/)){
- print "\n\nYour feedback was sent successfully, thank you!\n\n";
- }else{
- print "\n\nAn error ocurred while trying to send your feedback.
Please take\n";
- print "your time to write it to
<feedbackml>\@perfsonar.net,
it's very \n";
- print "important to us. Thank you!\n";
- print "Press any key to continue...\n";
- <STDIN>;
- }
+ if ( $res->is_success && !( $res->as_string =~ /NOT-OK/ ) ) {
+ print "\n\nYour feedback was sent successfully, thank
you!\n\n";
+ }
+ else {
+ print
+"\n\nAn error ocurred while trying to send your feedback. Please take\n";
+ print
+ "your time to write it to
<feedbackml>\@perfsonar.net,
it's very \n";
+ print "important to us. Thank you!\n";
+ print "Press any key to continue...\n";
+ <STDIN>;
+ }
}

-sub getProperties(){
- my $menu;
- my $const;
-
- if (!$isPerl){
- if (system("test -f
".$serviceDir."classes/perfsonar/conf/const.properties") != 0){
- $menu = "\nI could not find the const.properties file last used
for this \n";
- $menu .= "service. If you know it's location you can now type
it's path or \n";
- $menu .= "else just press enter to use the one currently in the
configured \n";
- $menu .= "installation directory. \n";
- print $menu;
- $const = <STDIN>;
- chomp($const);
+sub getProperties() {
+ my $menu;
+ my $const;

- if (!($const =~ /const.properties$/) || system("test -f
".$const) != 0){
- if ($const ne ''){
- print "\nThe file $const doesn't seems to be valid.\n\n";
- }
- print "Using the one currently in the installation
directory...\n";
- }else{
- if (system("cp $const ".$installDir."ant/") != 0){
- $menu = "\nAn error occurred when trying to copy the
given file to \n";
- $menu .= $installDir."ant/. \n";
- $menu .= "You can try to do this manually, otherwise the
const.properties file \n";
- $menu .= "already located in the installation directory
will be used. \n";
- $menu .= "Press any key when you're ready to continue...
\n";
- print $menu;
- <STDIN>;
- }else{
- print "File copied successfully. Continuing...\n";
- }
- system("cp $const ".$serviceDir.
- "classes/perfsonar/conf/const.properties
".$installDir."ant/ 2> /dev/null");
- }
- }else{
- print "\nI'm now copying the latest configuration used for this
service...\n";
- if (system("cp ".$serviceDir.
- "classes/perfsonar/conf/const.properties
".$installDir."ant/" != 0)){
+ if ( !$isPerl ) {
+ if (
+ system(
+ "test -f "
+ . $serviceDir
+ . "classes/perfsonar/conf/const.properties"
+ ) != 0
+ )
+ {
+ $menu =
+"\nI could not find the const.properties file last used for this \n";
+ $menu .=
+"service. If you know it's location you can now type it's path or \n";
+ $menu .=
+"else just press enter to use the one currently in the configured \n";
+ $menu .= "installation directory. \n";
+ print $menu;
+ $const = <STDIN>;
+ chomp($const);

- $menu = "\nAn error occurred when trying to copy the file
const.properties from \n";
- $menu .= $serviceDir."classes/perfsonar/conf/. \n";
- $menu .= "You can try to do this manually, otherwise the
const.properties file \n";
- $menu .= "already located in the installation directory will
be used. \n";
- $menu .= "Press any key when you're ready to continue... \n";
- print $menu;
- <STDIN>;
- }
- }
- }else{
- my $ok = '';
- if (system("test -d ".$serviceDir.".install") == 0){
- chdir($serviceDir.".install");
- if (system("cp configure deploy undeploy test $installDir") ==
0){
- $ok = 'true';
- }
- chdir($currentDir);
- }
- if (!$ok){
- $menu = "\nI couldn't copy the installation files last used for
this service.\n";
- $menu .= "The files configure, deploy, test and undeploy, which
should be in \n";
- $menu .= "the directory $serviceDir.install/, \n";
- $menu .= "should be copied to $installDir. \n";
- $menu .= "If these files are not copied, the files currently in
the installation \n";
- $menu .= "directory will be used.\n";
- $menu .= "Press any key when you're ready to continue... \n";
- print $menu;
- <STDIN>;
- }
- }
+ if ( !( $const =~ /const.properties$/ )
+ || system( "test -f " . $const ) != 0 )
+ {
+ if ( $const ne '' ) {
+ print "\nThe file $const doesn't
seems to be valid.\n\n";
+ }
+ print
+ "Using the one currently in the
installation directory...\n";
+ }
+ else {
+ if ( system( "cp $const " . $installDir .
"ant/" ) != 0 ) {
+ $menu =
+"\nAn error occurred when trying to copy the given file to \n";
+ $menu .= $installDir . "ant/. \n";
+ $menu .=
+"You can try to do this manually, otherwise the const.properties file \n";
+ $menu .=
+"already located in the installation directory will be used. \n";
+ $menu .=
+ "Press any key when you're ready to
continue... \n";
+ print $menu;
+ <STDIN>;
+ }
+ else {
+ print "File copied successfully.
Continuing...\n";
+ }
+ system( "cp $const "
+ . $serviceDir
+ .
"classes/perfsonar/conf/const.properties "
+ . $installDir
+ . "ant/ 2> /dev/null" );
+ }
+ }
+ else {
+ print
+"\nI'm now copying the latest configuration used for this service...\n";
+ if (
+ system(
+ "cp "
+ . $serviceDir
+ .
"classes/perfsonar/conf/const.properties "
+ . $installDir
+ . "ant/" != 0
+ )
+ )
+ {
+
+ $menu =
+"\nAn error occurred when trying to copy the file const.properties from \n";
+ $menu .= $serviceDir .
"classes/perfsonar/conf/. \n";
+ $menu .=
+"You can try to do this manually, otherwise the const.properties file \n";
+ $menu .=
+"already located in the installation directory will be used. \n";
+ $menu .= "Press any key when you're ready to
continue... \n";
+ print $menu;
+ <STDIN>;
+ }
+ }
+ }
+ else {
+ my $ok = '';
+ if ( system( "test -d " . $serviceDir . ".install" ) == 0 ) {
+ chdir( $serviceDir . ".install" );
+ if ( system("cp configure deploy undeploy test
$installDir") == 0 )
+ {
+ $ok = 'true';
+ }
+ chdir($currentDir);
+ }
+ if ( !$ok ) {
+ $menu =
+"\nI couldn't copy the installation files last used for this service.\n";
+ $menu .=
+"The files configure, deploy, test and undeploy, which should be in \n";
+ $menu .= "the directory $serviceDir.install/, \n";
+ $menu .= "should be copied to $installDir. \n";
+ $menu .=
+"If these files are not copied, the files currently in the installation \n";
+ $menu .= "directory will be used.\n";
+ $menu .= "Press any key when you're ready to
continue... \n";
+ print $menu;
+ <STDIN>;
+ }
+ }
}

sub modifyMenu() {
- my $menu;
- my $choice;
- my $invalid = 1;
- my $i;
- my $serviceName;
+ my $menu;
+ my $choice;
+ my $invalid = 1;
+ my $i;
+ my $serviceName;

- &getWebapps();
+ &getWebapps();

- &getServiceDir();
+ &getServiceDir();

- for my $key ( keys %serviceMap ) {
- if ($serviceDir =~ /$serviceMap{$key}/){
- $service = $key;
- }
- }
+ for my $key ( keys %serviceMap ) {
+ if ( $serviceDir =~ /$serviceMap{$key}/ ) {
+ $service = $key;
+ }
+ }

- if ($service){
- if ($service >= PERL()){
- $isPerl = 'true';
- }
- &installDir();
- }else {
- print "\nI couldn't detect the type of the service you want \n";
- print "to modify. You'll need to do this manually: \n";
- &serviceMenu();
- &installDir();
- }
+ if ($service) {
+ if ( $service >= PERL() ) {
+ $isPerl = 'true';
+ }
+ &installDir();
+ }
+ else {
+ print "\nI couldn't detect the type of the service you want
\n";
+ print "to modify. You'll need to do this manually: \n";
+ &serviceMenu();
+ &installDir();
+ }
}

sub getServiceDir() {
- my $menu;
- my $choice;
- my $invalid = 1;
- my $i;
- my $serviceName;
+ 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";
+ 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/.*\///;
- $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;
+ for ( $i = 0 ; $i < scalar(@dirs) ; $i++ ) {
+ $serviceName = $dirs[$i];
+ $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);
+ $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 directory of the
desired service:\n";
- $serviceDir = <STDIN>;
- chomp($serviceDir);
+ if ( $choice >= 1 && $choice <= $i ) {
+ $serviceDir = $dirs[ $choice - 1 ];
+ $invalid = 0;
+ }
+ elsif ( $choice eq ( $i + 1 ) ) {

- if ($serviceDir =~ /\/$/){
- $serviceDir .= '/';
- }
+ print
+"\nPlease type the path to the directory of the desired service:\n";
+ $serviceDir = <STDIN>;
+ chomp($serviceDir);

- if (system("test -d ".$serviceDir) != 0 ||
- (system("test -d ".$serviceDir."WEB-INF") != 0
- && system("test -f
".$serviceDir."bin/perfsonar.pl") != 0)) {
- 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 (!($serviceDir =~ /\/$/)){
- $serviceDir .= '/';
- }
+ if (
+ system( "test -d " . $serviceDir ) != 0
+ || ( system( "test -d " . $serviceDir
. "WEB-INF" ) != 0
+ && system(
+ "test -f " .
$serviceDir . "bin/perfsonar.pl" ) !=
+ 0 )
+ )
+ {
+ print
+"\nDirectory $serviceDir doesn't seems to be a valid directory.\n\n";
+ }
+ else {
+ $invalid = 0;
+ }
+ }
+ elsif ( $choice eq "" ) { exit; }
+ }

- if (system("test -d ".$serviceDir) != 0 ||
- (system("test -d ".$serviceDir."WEB-INF") != 0 &&
- system("test -f ".$serviceDir."bin/perfsonar.pl") != 0))
{
- print "\nDirectory $serviceDir doesn't seems to be a valid
directory.\n\n";
- 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
+ || ( system( "test -d " . $serviceDir . "WEB-INF" )
!= 0
+ && system( "test -f " . $serviceDir .
"bin/perfsonar.pl" ) !=
+ 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;
+ my $menu;
+ my $choice;
+ my $invalid = 1;
+ my $i;

- 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;
+ 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);
+ $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 ( $choice >= 1 && $choice <= $i ) {
+ $webappsDir = $dirs[ $choice - 1 ];
+ $invalid = 0;
+ }
+ elsif ( $choice eq ( $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 {
- `echo "webapps=$webappsDir" >> .install.conf`;
- $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);
+ if ( system( "test -d " . $webappsDir
) != 0 ) {
+ print
+"\nDirectory $webappsDir doesn't seems to be a valid directory.\n\n";
+ }
+ else {
+ `echo "webapps=$webappsDir"
>> .install.conf`;
+ $invalid = 0;
+ }
+ }
+ elsif ( $choice eq "" ) { 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 ne ''){
- $webappsDir = $choice;
- if ($webappsDir ne $dirs[0]){
- `echo "webapps=$webappsDir" >> .install.conf`;
- }
+ $webappsDir = $dirs[0];
+ if ( $choice ne '' ) {
+ $webappsDir = $choice;
+ if ( $webappsDir ne $dirs[0] ) {
+ `echo "webapps=$webappsDir" >>
.install.conf`;
+ }

- }
- 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 ( 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 ne ''){
- $webappsDir = $choice;
- if ($webappsDir ne $dirs[0]){
- `echo "webapps=$webappsDir" >> .install.conf`;
- }
- }
+ if ( $choice ne '' ) {
+ $webappsDir = $choice;
+ if ( $webappsDir ne $dirs[0] ) {
+ `echo "webapps=$webappsDir" >> .install.conf`;
+ }
+ }

- if (system("test -d ".$webappsDir) != 0){
- print "\nDirectory $webappsDir doesn't seems to be a valid
directory.\n\n";
- exit;
- }
+ if ( system( "test -d " . $webappsDir ) != 0 ) {
+ print
+"\nDirectory $webappsDir doesn't seems to be a valid directory.\n\n";
+ exit;
+ }

- }
+ }
}

-sub detectExistingService(){
- my @perl;
- my $i;
- @dirs = `find $webappsDir -type d -regex ".*WEB-INF\$"`;
- for ($i=0 ; $i < scalar(@dirs) ; $i++){
- $dirs[$i] =~ s/\/WEB-INF//;
- }
- @perl = `find $webappsDir -regex ".*bin/perfsonar\.pl\$"`;
- for ($i=0 ; $i < scalar(@perl) ; $i++){
- $perl[$i] =~ s/\/bin\/perfsonar\.pl//;
- }
- push(@dirs, @perl);
- chomp(@dirs);
- if (scalar(@dirs) > 0) { return 'true'; }
- else { return ''; }
+sub detectExistingService() {
+ my @perl;
+ my $i;
+ @dirs = `find $webappsDir -type d -regex ".*WEB-INF\$"`;
+ for ( $i = 0 ; $i < scalar(@dirs) ; $i++ ) {
+ $dirs[$i] =~ s/\/WEB-INF//;
+ }
+ @perl = `find $webappsDir -regex ".*bin/perfsonar\.pl\$"`;
+ for ( $i = 0 ; $i < scalar(@perl) ; $i++ ) {
+ $perl[$i] =~ s/\/bin\/perfsonar\.pl//;
+ }
+ push( @dirs, @perl );
+ chomp(@dirs);
+ if ( scalar(@dirs) > 0 ) { return 'true'; }
+ else { return ''; }
}

-sub detectWebapps(){
- my @confSD;
- @dirs = `find $currentDir -type d -regex ".*webapps\$" | grep -v
apache-tomcat`;
- @confSD = `cat .install.conf | grep webapps | cut -d "=" -f 2`;
- push(@dirs, @confSD);
- chomp(@dirs);
- if (scalar(@dirs) > 0) { return 'true' }
- else { return '' };
+sub detectWebapps() {
+ my @confSD;
+ @dirs =
+ `find $currentDir -type d -regex ".*webapps\$" | grep -v
apache-tomcat`;
+ @confSD = `cat .install.conf | grep webapps | cut -d "=" -f 2`;
+ push( @dirs, @confSD );
+ chomp(@dirs);
+ if ( scalar(@dirs) > 0 ) { return 'true' }
+ else { return '' }
}

sub installDir() {
- my $menu;
- my $choice;
- my $invalid = 1;
- my $i;
+ 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";
- if ($modification) {
- $menu .= "(These files are also needed for service
modifications.) \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. \n";
- if ($modification) {
- $menu .= "(These files are also needed for service
modifications.) \n";
- }
- $menu .= "If you have already downloaded and extracted these files,
\n";
- $menu .= "you can choose to give the directory location. Otherwise,
\n";
- $menu .= "choose to download the installation files. \n\n";
- }
+ if ( &detectExistingInstall() ) {
+ $menu .= "\nI have detected that there might be directories
which \n";
+ $menu .= "already have the installation files for this
service. \n";
+ if ($modification) {
+ $menu .=
+ "(These files are also needed for service
modifications.) \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. \n";
+ if ($modification) {
+ $menu .=
+ "(These files are also needed for service
modifications.) \n";
+ }
+ $menu .= "If you have already downloaded and extracted these
files, \n";
+ $menu .= "you 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 $serviceDisplayMap{$service}
installation files directory\n";
+ $menu .= "What do you want to do?\n";
+ $menu .= "1. Download installation files\n";
+ $menu .=
+"2. Give the path to existing $serviceDisplayMap{$service} installation
files directory\n";

- for ($i=0 ; $i < scalar(@dirs) ; $i++){
- if ($isPerl){
- $dirs[$i] =~ s/\/pre-install$/\//;
- }else{
- $dirs[$i] =~ s/\/ant$/\//;
- }
- $menu .= ($i+3).". Use ".$dirs[$i]."\n";
- }
- $menu .= "Please choose a number [enter to exit]: ";
- $i = $i + 3;
+ for ( $i = 0 ; $i < scalar(@dirs) ; $i++ ) {
+ if ($isPerl) {
+ $dirs[$i] =~ s/\/pre-install$/\//;
+ }
+ else {
+ $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;
+ while ($invalid) {
+ print $menu;

- $choice = <STDIN>;
- chomp($choice);
+ $choice = <STDIN>;
+ chomp($choice);

- switch ($choice){
- case 1 { $invalid = &download(); }
- case 2 {
- print "\nPlease type the path to service
$serviceDisplayMap{$service}'s installation files \n";
- print "directory: ";
- $installDir = <STDIN>;
- chomp($installDir);
+ if ( $choice eq 1 ) { $invalid = &download(); }
+ elsif ( $choice eq 2 ) {
+ print
+"\nPlease type the path to service $serviceDisplayMap{$service}'s
installation files \n";
+ print "directory: ";
+ $installDir = <STDIN>;
+ chomp($installDir);

- if (!($installDir =~ /\/$/)){
- $installDir .= '/';
- }
+ if ( !( $installDir =~ /\/$/ ) ) {
+ $installDir .= '/';
+ }

- if (!$isPerl){
- if (!($installDir =~ /perfsonar\/$/)){
- $installDir .= 'perfsonar/';
- }
+ if ( !$isPerl ) {
+ 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 {
- `echo "$serviceMap{$service}=$installDir" >>
.install.conf`;
- $invalid = 0;
- }
- }else{
- if (system("test -f ".$installDir."pre-install") != 0){
- print "\nDirectory $installDir doesn't seems to be a
valid directory.\n\n";
- }else {
- `echo "$serviceMap{$service}=$installDir" >>
.install.conf`;
- $invalid = 0;
- }
- }
- }
- case [3..$i] {
- $installDir = $dirs[$choice-3];
- $invalid = 0;
- }
- case "" { exit; }
- else { print "\nPlease type a valid number.\n"; }
- }
- }
+ if ( system( "test -f " . $installDir .
"ant/build.xml" ) != 0 )
+ {
+ print
+"\nDirectory $installDir doesn't seems to be a valid directory.\n\n";
+ }
+ else {
+ `echo
"$serviceMap{$service}=$installDir" >> .install.conf`;
+ $invalid = 0;
+ }
+ }
+ else {
+ if ( system( "test -f " . $installDir .
"pre-install" ) != 0 ) {
+ print
+"\nDirectory $installDir doesn't seems to be a valid directory.\n\n";
+ }
+ else {
+ `echo
"$serviceMap{$service}=$installDir" >> .install.conf`;
+ $invalid = 0;
+ }
+ }
+ }
+ if ( $choice >= 3 && $choice <= $i ) {
+ $installDir = $dirs[ $choice - 3 ];
+ $invalid = 0;
+ }
+ elsif ( $choice eq "" ) { exit; }
+ else { print "\nPlease type a valid number.\n"; }

- chomp($installDir);
+ }

+ chomp($installDir);
+
}

-sub download(){
- my $menu;
- my $choice;
- my $file = $serviceFilesTar{$service};
-
- print "\nDownloading installation files for service
".$serviceDisplayMap{$service}.".\n";
- print "This might take a while depending on your connection
speed...\n\n";
-
- print "Please do not press any key until the file download process is
complete.\n";
- print "When the download process has finished, press any key. Okay?
\n\n";
- <STDIN>;
-
- my $systemSignal = system("wget $servicesTar{$service}");
- <STDIN>;
- if ($systemSignal != 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>;
- }
+sub download() {
+ my $menu;
+ my $choice;
+ my $file = $serviceFilesTar{$service};

- `test -s $file` == 0 or die "FATAL: file $file is not present.";
+ print "\nDownloading installation files for service "
+ . $serviceDisplayMap{$service} . ".\n";
+ print "This might take a while depending on your connection
speed...\n\n";

- $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);
+ print
+"Please do not press any key until the file download process is complete.\n";
+ print "When the download process has finished, press any key. Okay?
\n\n";
+ <STDIN>;

- $installDir = $currentDir;
- if ($choice != ''){
- if (!($choice =~ /\/$/)){
- $choice = $choice . "/";
- }
+ my $systemSignal = system("wget $servicesTar{$service}");
+ <STDIN>;
+ if ( $systemSignal != 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>;
+ }

- $installDir = $choice
- }
+ `test -s $file` == 0 or die "FATAL: file $file is not present.";

- print "\nExtracting service $serviceDisplayMap{$service} installation
files...\n\n";
+ $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);

- if (system("gzip -d $file") != 0){
- print "\nAn error occurred while trying to unzip the installions
files.\n";
- print "\nReturning to the last menu...\n";
- return 1;
- }
- my @arr=split /\.gz/, $file;
+ $installDir = $currentDir;
+ if ( $choice != '' ) {
+ if ( !( $choice =~ /\/$/ ) ) {
+ $choice = $choice . "/";
+ }
+
+ $installDir = $choice;
+ }
+
+ print
+"\nExtracting service $serviceDisplayMap{$service} installation
files...\n\n";
+
+ if ( system("gzip -d $file") != 0 ) {
+ print
+ "\nAn error occurred while trying to unzip the installions
files.\n";
+ print "\nReturning to the last menu...\n";
+ return 1;
+ }
+ my @arr = split /\.gz/, $file;
my $file_unzipped = $arr[0];
-
- if (system("tar -xvf $file_unzipped -C $installDir") != 0){
- print "\nAn error occurred while trying to extract the installions
files.\n";
- print "\nReturning to the last menu...\n";
- return 1;
- }

- $file =~ s/\.tar.*//;
- $installDir .= $file."/";
- if (!$isPerl){
- $installDir .= "perfsonar/";
- }
+ if ( system("tar -xvf $file_unzipped -C $installDir") != 0 ) {
+ print
+"\nAn error occurred while trying to extract the installions files.\n";
+ print "\nReturning to the last menu...\n";
+ return 1;
+ }

- if (!($installDir =~ /^\./) && !($installDir =~ /$currentDir/)){
- `echo "$serviceMap{$service}=$installDir" >> .install.conf`;
- }
+ $file =~ s/\.tar.*//;
+ $installDir .= $file . "/";
+ if ( !$isPerl ) {
+ $installDir .= "perfsonar/";
+ }

- return 0;
+ if ( !( $installDir =~ /^\./ ) && !( $installDir =~ /$currentDir/ ) )
{
+ `echo "$serviceMap{$service}=$installDir" >> .install.conf`;
+ }
+
+ return 0;
}

-sub serviceMenu(){
- my $menu = "";
- my $key = 1;
- my $tmp = $serviceDisplayMap{$key};
+sub serviceMenu() {
+ my $menu = "";
+ my $key = 1;
+ my $tmp = $serviceDisplayMap{$key};

- while ($tmp ne '') {
- $menu .= "$key. $serviceDisplayMap{$key}\n";
- $key++;
- $tmp = $serviceDisplayMap{$key};
- }
- $menu .= "Please choose a number [enter to exit]: ";
- print $menu;
- $service = <STDIN>;
- chomp($service);
+ while ( $tmp ne '' ) {
+ $menu .= "$key. $serviceDisplayMap{$key}\n";
+ $key++;
+ $tmp = $serviceDisplayMap{$key};
+ }
+ $menu .= "Please choose a number [enter to exit]: ";
+ print $menu;
+ $service = <STDIN>;
+ chomp($service);

- if ($service eq ''){
- exit;
- }
+ if ( $service eq '' ) {
+ exit;
+ }

- if (!($service =~ /^[1-9]$/) || $service >= $key){
- print "\nPlease type a valid number.\n";
- &serviceMenu();
- }
+ if ( !( $service =~ /^[1-9]$/ ) || $service >= $key ) {
+ print "\nPlease type a valid number.\n";
+ &serviceMenu();
+ }

- if ($service >= PERL()){
- $isPerl = 'true';
- }else{
- $isPerl = '';
- }
+ if ( $service >= PERL() ) {
+ $isPerl = 'true';
+ }
+ else {
+ $isPerl = '';
+ }
}

-sub detectExistingInstall(){
- my @perl;
- my @confSD;
- @dirs = `find $currentDir -type d -regex
".*$serviceMap{$service}.*/perfsonar/ant\$"`;
- @perl = `find $currentDir -regex
".*$serviceMap{$service}.*/pre-install\$"`;
- @confSD = `cat .install.conf | grep $serviceMap{$service} | cut -d "="
-f 2`;
- chomp(@perl);
- push(@dirs, @perl);
- push(@dirs, @confSD);
- if (scalar(@dirs) > 0) { return 'true' }
- else { return '' };
+sub detectExistingInstall() {
+ my @perl;
+ my @confSD;
+ @dirs =
+`find $currentDir -type d -regex
".*$serviceMap{$service}.*/perfsonar/ant\$"`;
+ @perl = `find $currentDir -regex
".*$serviceMap{$service}.*/pre-install\$"`;
+ @confSD =
+ `cat .install.conf | grep $serviceMap{$service} | cut -d "=" -f 2`;
+ chomp(@perl);
+ push( @dirs, @perl );
+ push( @dirs, @confSD );
+ 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 [enter to exit]: ";
+sub installTypeMenu() {
+ my $menu = "\nWhich installation type do you want?\n";
+ $menu .= "1. Basic\n";
+ $menu .= "2. Advanced\n";
+ $menu .= "Please choose a number [enter to exit]: ";

- print $menu;
- my $choice = <STDIN>;
- chomp($choice);
+ print $menu;
+ 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 ( $choice eq 1 ) { &basic(); }
+ elsif ( $choice eq 2 ) { &advanced(); }
+ elsif ( $choice eq "" ) { exit; }
+ else { print "\nPlease type a valid number.\n"; &installTypeMenu(); }
+
}

-sub basic(){
- my $verbose = '';
- if ($service == SSH()){
- $verbose = 'true';
- }
+sub basic() {
+ my $verbose = '';
+ if ( $service == SSH() ) {
+ $verbose = 'true';
+ }

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

- if ($returnCode != 0){
- &error();
- if ($answer =~ /^y$/ or $answer =~ /^yes$/){
- &action('pre-install');
- }
- if ($returnCode != 0){
- return;
- }
- }
+ if ( $returnCode != 0 ) {
+ &error();
+ if ( $answer =~ /^y$/ or $answer =~ /^yes$/ ) {
+ &action('pre-install');
+ }
+ if ( $returnCode != 0 ) {
+ return;
+ }
+ }

- &action('configure', $verbose);
+ &action( 'configure', $verbose );

- if ($returnCode != 0){
- &error();
- if ($answer =~ /^y$/ or $answer =~ /^yes$/){
- &action('configure', $verbose);
- }
- if ($returnCode != 0){
- return;
- }
- }
+ if ( $returnCode != 0 ) {
+ &error();
+ if ( $answer =~ /^y$/ or $answer =~ /^yes$/ ) {
+ &action( 'configure', $verbose );
+ }
+ if ( $returnCode != 0 ) {
+ return;
+ }
+ }

- &action('deploy');
+ &action('deploy');

- if ($returnCode != 0){
- &error();
- if ($answer =~ /^y$/ or $answer =~ /^yes$/){
- &action('deploy');
- }
- if ($returnCode != 0){
- return;
- }
- }
+ if ( $returnCode != 0 ) {
+ &error();
+ if ( $answer =~ /^y$/ or $answer =~ /^yes$/ ) {
+ &action('deploy');
+ }
+ if ( $returnCode != 0 ) {
+ return;
+ }
+ }

- &copyProperties();
+ &copyProperties();

- &test();
- if ($answer =~ /^y$/ or $answer =~ /^yes$/){
- &action('test', 1);
- }
+ &test();
+ if ( $answer =~ /^y$/ or $answer =~ /^yes$/ ) {
+ &action( 'test', 1 );
+ }

}

-sub test(){
- my $menu = "\nApparently the installation was successful.\n";
- $menu .= "Would you like to test the service? (y, n): ";
- print $menu;
- $answer = <STDIN>;
+sub test() {
+ my $menu = "\nApparently the installation was successful.\n";
+ $menu .= "Would you like to test the service? (y, n): ";
+ print $menu;
+ $answer = <STDIN>;
}

-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 .= "(yes [y] or [yes] to try, anything else goes back to the
installation menu): ";
- print $menu;
- $answer = <STDIN>;
+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 .=
+"(yes [y] or [yes] to try, anything else goes back to the installation
menu): ";
+ print $menu;
+ $answer = <STDIN>;
}

-sub advanced(){
- my $menu = "\nAvailable actions: \n";
- $menu .= "1. pre-install\n";
- $menu .= "2. configure\n";
- $menu .= "3. deploy\n";
- $menu .= "4. test\n";
- $menu .= "5. undeploy\n";
- $menu .= "6. enable/disable verbose\n";
- $menu .= "7. restart script\n";
- $menu .= "0. exit\n";
- $menu .= "Please choose a number: ";
- print $menu;
- my $choice = <STDIN>;
+sub advanced() {
+ my $menu = "\nAvailable actions: \n";
+ $menu .= "1. pre-install\n";
+ $menu .= "2. configure\n";
+ $menu .= "3. deploy\n";
+ $menu .= "4. test\n";
+ $menu .= "5. undeploy\n";
+ $menu .= "6. enable/disable verbose\n";
+ $menu .= "7. restart script\n";
+ $menu .= "0. exit\n";
+ $menu .= "Please choose a number: ";
+ print $menu;
+ my $choice = <STDIN>;

- chomp($choice);
+ chomp($choice);

- switch ($choice){
- case 1 { print "\nExecuting action pre-install...\n\n";
&action('pre-install', $verbose); }
- case 2 {
- print "\nExecuting action configure...\n\n";
- if ($service == SSH()){ &action('configure', 1); }
- else { &action('configure', $verbose); }
- }
- case 3 {
- print "\nExecuting action deploy...\n\n";
&action('deploy', $verbose);
- &copyProperties();
- }
- case 4 { print "\nExecuting action test...\n\n";
&action('test', 1); }
- case 5 { print "\nExecuting action undeploy...\n\n";
&action('undeploy', $verbose); }
- case 6 {
- if ($verbose) { $verbose = 0; print "\nVerbose
installation has been disabled.\n"; }
- else { $verbose = 'true'; print "\nVerbose
installation has been enabled.\n"; }
- }
- case 7 { return; }
- case 0 { exit; }
- else { print "\nPlease type a valid option.\n"; }
- }
+ if ( $choice eq 1 ) {
+ print "\nExecuting action pre-install...\n\n";
+ &action( 'pre-install', $verbose );
+ }
+ elsif ( $choice eq 2 ) {
+ print "\nExecuting action configure...\n\n";
+ if ( $service == SSH() ) { &action( 'configure', 1 ); }
+ else { &action( 'configure', $verbose ); }
+ }
+ elsif ( $choice eq 3 ) {
+ print "\nExecuting action deploy...\n\n";
+ &action( 'deploy', $verbose );
+ &copyProperties();
+ }
+ elsif ( $choice eq 4 ) {
+ print "\nExecuting action test...\n\n";
+ &action( 'test', 1 );
+ }
+ elsif ( $choice eq 4 ) {
+ print "\nExecuting action undeploy...\n\n";
+ &action( 'undeploy', $verbose );
+ }
+ elsif( $choice eq 6 ) {
+ if ($verbose)
+ {
+ $verbose = 0;
+ print "\nVerbose installation has been disabled.\n";
+ }
+ else {
+ $verbose = 'true';
+ print "\nVerbose installation has been enabled.\n";
+ }
+ } elsif ( $choice eq 7 ) {
+ return;
+ }
+ elsif ( $choice eq 0 ) { exit; }
+ else { print "\nPlease type a valid option.\n"; }

- &advanced();
+ &advanced();

}

-sub action(){
- my $target = shift(@_);
- my $notQuiet = shift(@_);
- if (!$isPerl){
- chdir($installDir."ant");
- if ($notQuiet){
- $returnCode = system "ant -f build.xml " . $target;
- }else{
- $returnCode = system "ant -q -f build.xml " . $target;
- }
- }else{
- chdir($installDir);
- $returnCode = system "perl ".$target;
- }
- chdir($currentDir);
+sub action() {
+ my $target = shift(@_);
+ my $notQuiet = shift(@_);
+ if ( !$isPerl ) {
+ chdir( $installDir . "ant" );
+ if ($notQuiet) {
+ $returnCode = system "ant -f build.xml " . $target;
+ }
+ else {
+ $returnCode = system "ant -q -f build.xml " . $target;
+ }
+ }
+ else {
+ chdir($installDir);
+ $returnCode = system "perl " . $target;
+ }
+ chdir($currentDir);
}

-sub copyProperties(){
- my $menu;
+sub copyProperties() {
+ my $menu;

- if (!$isPerl){
- my $tmp = $installDir."ant/const.properties";
- my $web = `cat $tmp | grep "service.home" | cut -d '=' -f 2`;
- chomp($web);
- my $name = `cat $tmp | grep "^service.name" | cut -d '=' -f 2`;
- chomp($name);
-
- if ($name eq ''){
- $name = `cat $tmp | grep "^deploy.root" | cut -d '=' -f 2`;
- chomp($name);
- }
+ if ( !$isPerl ) {
+ my $tmp = $installDir . "ant/const.properties";
+ my $web = `cat $tmp | grep "service.home" | cut -d '=' -f 2`;
+ chomp($web);
+ my $name = `cat $tmp | grep "^service.name" | cut -d '=' -f
2`;
+ chomp($name);

- if (system("cp ".$installDir."ant/const.properties ".$web."/"
-
.$name."/WEB-INF/classes/perfsonar/conf/const.properties") != 0){
+ if ( $name eq '' ) {
+ $name = `cat $tmp | grep "^deploy.root" | cut -d '='
-f 2`;
+ chomp($name);
+ }

- $menu = "\nAn error occurred when trying to copy the file
const.properties to \n";
- $menu .= "the directory where the service was installed. The
directory used was: \n";
- $menu .= $web."/".$name."/WEB-INF/classes/perfsonar/conf/ \n";
- $menu .= "This file is copied so that it can be used in future
modifications \n";
- $menu .= "to the service through the use of this script. I
recommend that you \n";
- $menu .= "copy the file ".$installDir."ant/const.properties \n";
- $menu .= "to the mentioned directory (or to the right one if the
path detected \n";
- $menu .= "of the service's WEB-INF directory is wrong). \n";
- $menu .= "Press any key to continue...\n";
- print $menu;
- <STDIN>;
- }
- }else{
- my $ok = 'true';
- chdir($installDir);
- my $path = `cat configure | grep "my \\\$installpath" | cut -d '"'
-f 2`;
- chomp($path);
+ if (
+ system(
+ "cp "
+ . $installDir
+ . "ant/const.properties "
+ . $web . "/"
+ . $name
+ .
"/WEB-INF/classes/perfsonar/conf/const.properties"
+ ) != 0
+ )
+ {

- if (!($path =~ /\/$/)){
- $path .= "/";
- }
- if (system("test -d ".$path.".install") != 0){
- if (system("mkdir ".$path.".install") != 0){
- print "Please create the directory ".$path.".install now.\n";
- print "This directory is used by this installer script for
future modifications\n";
- print "or tests for the installed service.\n";
- print "Press any key when you're done...\n";
- <STDIN>;
- if (system("test -d ".$path.".install") == 0){
- $ok = '';
- }
- }
- }
- if($ok){
- if (system("cp configure deploy undeploy test
".$path.".install") != 0){
- $ok = '';
- }
- }
- if(!$ok){
- $menu = "\nAn error occurred when trying to copy some of the
installation files to\n";
- $menu .= "the directory where the service was installed. The
directory used was: \n";
- $menu .= $path.".install \n";
- $menu .= "This file is copied so that it can be used in future
modifications to\n";
- $menu .= "the service through the use of this script. I
recommend that you copy\n";
- $menu .= "the files configure, deploy, undeploy and test from
the directory\n";
- $menu .= "$installDir\n";
- $menu .= "to the first mentioned directory (creating it if
necessary, or correcting\n";
- $menu .= "the path if the detected service directory is wrong).
\n";
- $menu .= "Press any key to continue...\n";
- print $menu;
- <STDIN>;
- }
- chdir($installDir);
- }
+ $menu =
+"\nAn error occurred when trying to copy the file const.properties to \n";
+ $menu .=
+"the directory where the service was installed. The directory used was: \n";
+ $menu .= $web . "/" . $name .
"/WEB-INF/classes/perfsonar/conf/ \n";
+ $menu .=
+"This file is copied so that it can be used in future modifications \n";
+ $menu .=
+"to the service through the use of this script. I recommend that you \n";
+ $menu .= "copy the file " . $installDir .
"ant/const.properties \n";
+ $menu .=
+"to the mentioned directory (or to the right one if the path detected \n";
+ $menu .= "of the service's WEB-INF directory is
wrong). \n";
+ $menu .= "Press any key to continue...\n";
+ print $menu;
+ <STDIN>;
+ }
+ }
+ else {
+ my $ok = 'true';
+ chdir($installDir);
+ my $path =
+ `cat configure | grep "my \\\$installpath" | cut -d '"' -f
2`;
+ chomp($path);
+
+ if ( !( $path =~ /\/$/ ) ) {
+ $path .= "/";
+ }
+ if ( system( "test -d " . $path . ".install" ) != 0 ) {
+ if ( system( "mkdir " . $path . ".install" ) != 0 ) {
+ print "Please create the directory " . $path
+ . ".install now.\n";
+ print
+"This directory is used by this installer script for future modifications\n";
+ print "or tests for the installed service.\n";
+ print "Press any key when you're done...\n";
+ <STDIN>;
+ if ( system( "test -d " . $path . ".install"
) == 0 ) {
+ $ok = '';
+ }
+ }
+ }
+ if ($ok) {
+ if (
+ system(
+ "cp configure deploy undeploy test "
. $path . ".install"
+ ) != 0
+ )
+ {
+ $ok = '';
+ }
+ }
+ if ( !$ok ) {
+ $menu =
+"\nAn error occurred when trying to copy some of the installation files
to\n";
+ $menu .=
+"the directory where the service was installed. The directory used was: \n";
+ $menu .= $path . ".install \n";
+ $menu .=
+"This file is copied so that it can be used in future modifications to\n";
+ $menu .=
+"the service through the use of this script. I recommend that you copy\n";
+ $menu .=
+"the files configure, deploy, undeploy and test from the directory\n";
+ $menu .= "$installDir\n";
+ $menu .=
+"to the first mentioned directory (creating it if necessary, or
correcting\n";
+ $menu .= "the path if the detected service directory
is wrong). \n";
+ $menu .= "Press any key to continue...\n";
+ print $menu;
+ <STDIN>;
+ }
+ chdir($installDir);
+ }
}



  • perfsonar: r2466 - trunk/perfsonar-bundle, svnlog, 06/07/2007

Archive powered by MHonArc 2.6.16.

Top of Page