From 5734bcd664f92dd29f40d3cb8fad85547e6c9fef Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Fri, 8 Sep 2017 07:52:01 +0000 Subject: use Defaults::vespaHostname --- config/src/apps/vespa-config/vespa-config.pl | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'config/src') diff --git a/config/src/apps/vespa-config/vespa-config.pl b/config/src/apps/vespa-config/vespa-config.pl index cc0daed3e7d..d54d7af4418 100755 --- a/config/src/apps/vespa-config/vespa-config.pl +++ b/config/src/apps/vespa-config/vespa-config.pl @@ -72,6 +72,8 @@ use warnings; use File::Copy; use File::Temp; +my $myHostname = `vespa-print-default hostname`; +chomp $myHostname; my $default_configproxy_port = "19090"; my $default_configserver_port = "19070"; my $zk_client_port; @@ -155,10 +157,7 @@ sub printConfigServerPort { sub getConfigServers { my @ret; - my $hostname = `hostname`; - chomp $hostname; - - my $addr = getVar('addr_configserver', $hostname, 1); + my $addr = getVar('addr_configserver', $myHostname, 1); my $port = getVar('port_configserver_rpc', $default_configserver_port, 0); my $h; @@ -253,9 +252,7 @@ sub makeFiledistributorDistributorConfig { my $cfgFile = $VESPA_HOME . "/conf/filedistributor/filedistributor.cfg"; open(CFG, "> ${cfgFile}.new") or die "Cannot write to '${cfgFile}.new'"; print CFG "torrentport 19093\n"; - my $hostname = `hostname`; - chomp $hostname; - print CFG "hostname \"$hostname\"\n"; + print CFG "hostname \"$myHostname\"\n"; print CFG "filedbpath \"$VESPA_HOME" . "/var/db/vespa/filedistribution\"\n"; print CFG "maxdownloadspeed 0\n"; print CFG "maxuploadspeed 0\n"; @@ -268,9 +265,7 @@ sub makeFiledistributorDistributorConfig { sub makeFiledistributorRpcConfig { my $cfgFile = $VESPA_HOME . "/conf/filedistributor/filedistributorrpc.cfg"; open(CFG, "> ${cfgFile}.new") or die "Cannot write to '${cfgFile}.new'"; - my $hostname = `hostname`; - chomp $hostname; - print CFG "connectionspec \"tcp/$hostname:19092\"\n"; + print CFG "connectionspec \"tcp/$myHostname:19092\"\n"; close(CFG); rename("${cfgFile}.new", ${cfgFile}) or die "Cannot rename '${cfgFile}.new' -> '${cfgFile}': $!\n"; @@ -294,8 +289,6 @@ sub makeFiledistributorConfig { } sub isThisAConfigServer { - my $hostnameForThisHost = `hostname`; - chomp $hostnameForThisHost; my $addr; foreach $addr (getConfigServers()) { my $host = ""; @@ -303,7 +296,7 @@ sub isThisAConfigServer { if ($addr =~ /(.*):(\d+)$/) { $host = $1; } - if ($hostnameForThisHost eq $host or $host eq "localhost") { + if ($myHostname eq $host or $host eq "localhost") { print "yes\n"; exit 0; } -- cgit v1.2.3