diff options
author | Arne Juul <arnej@yahoo-inc.com> | 2018-05-11 10:12:45 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahoo-inc.com> | 2018-05-14 10:08:15 +0000 |
commit | 8bd5c123f149dd3c4a0b05231b27ddedc207e5b6 (patch) | |
tree | b3b07075bf2bc0c9ccd6c5457112a3a5530b9ad1 /jdisc_core/src | |
parent | cc5f5b2b41db293a9ce7ef554adde9e776fd1ad2 (diff) |
simpler bootstrap
Diffstat (limited to 'jdisc_core/src')
-rwxr-xr-x | jdisc_core/src/main/perl/vespa-jdisc-logfmt | 70 |
1 files changed, 5 insertions, 65 deletions
diff --git a/jdisc_core/src/main/perl/vespa-jdisc-logfmt b/jdisc_core/src/main/perl/vespa-jdisc-logfmt index dcada283fc9..655fd8da24c 100755 --- a/jdisc_core/src/main/perl/vespa-jdisc-logfmt +++ b/jdisc_core/src/main/perl/vespa-jdisc-logfmt @@ -1,76 +1,16 @@ #!/usr/bin/env perl # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -# BEGIN perl environment bootstrap section -# Do not edit between here and END as this section should stay identical in all scripts - -use File::Basename; -use File::Path; - -sub findpath { - my $myfullname = ${0}; - my($myname, $mypath) = fileparse($myfullname); - - return $mypath if ( $mypath && -d $mypath ); - $mypath=`pwd`; - - my $pwdfullname = $mypath . "/" . $myname; - return $mypath if ( -f $pwdfullname ); - return 0; -} - -# Returns the argument path if it seems to point to VESPA_HOME, 0 otherwise -sub is_vespa_home { - my($VESPA_HOME) = shift; - my $COMMON_ENV="libexec/vespa/common-env.sh"; - if ( $VESPA_HOME && -d $VESPA_HOME ) { - my $common_env = $VESPA_HOME . "/" . $COMMON_ENV; - return $VESPA_HOME if -f $common_env; - } - return 0; -} - -# Returns the home of Vespa, or dies if it cannot sub findhome { # Try the VESPA_HOME env variable - return $ENV{'VESPA_HOME'} if is_vespa_home($ENV{'VESPA_HOME'}); - if ( $ENV{'VESPA_HOME'} ) { # was set, but not correctly - die "FATAL: bad VESPA_HOME value '" . $ENV{'VESPA_HOME'} . "'\n"; + return $ENV{'VESPA_HOME'} if defined $ENV{'VESPA_HOME'}; + if ( $0 =~ m{(.*)/bin[^/]*/[^/]*logfmt[^/]*$} ) { + return $1; } - - # Try the ROOT env variable - $ROOT = $ENV{'ROOT'}; - return $ROOT if is_vespa_home($ROOT); - - # Try the script location or current dir - my $mypath = findpath(); - if ($mypath) { - while ( $mypath =~ s|/[^/]*$|| ) { - return $mypath if is_vespa_home($mypath); - } - } - die "FATAL: Missing VESPA_HOME environment variable\n"; -} - -sub findhost { - $ENV{'PATH'} = $ENV{'VESPA_HOME'} . '/bin:' . $ENV{'PATH'}; - my $tmp = $ENV{'VESPA_HOSTNAME'}; - if (!defined $tmp) { - $tmp = `vespa-detect-hostname` or die "Could not detect hostname\n"; - } - system("vespa-validate-hostname $tmp"); - ( $? == 0 ) or die "Could not validate hostname\n"; -} - -BEGIN { - my $tmp = findhome(); - $ENV{'VESPA_HOME'} = $tmp; - $tmp = findhost(); - $ENV{'VESPA_HOSTNAME'} = $tmp; + return "/opt/vespa"; } -my $VESPA_HOME = $ENV{'VESPA_HOME'}; -# END perl environment bootstrap section +my $VESPA_HOME = findhome(); # TODO: Remove on Vespa 7 |