diff options
author | Fred Hebert <[email protected]> | 2018-06-19 10:15:53 -0400 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2018-06-19 08:15:53 -0600 |
commit | d1ee878732ead9fc381999e2340cfb8d25e77066 (patch) | |
tree | a2571c4eed3c26bd02ebff042e81fa45dea91fc5 /priv/templates/extended_bin_windows | |
parent | cc85c34d483539acbf4f249b6add7c20de29f39d (diff) | |
download | relx-d1ee878732ead9fc381999e2340cfb8d25e77066.tar.gz relx-d1ee878732ead9fc381999e2340cfb8d25e77066.tar.bz2 relx-d1ee878732ead9fc381999e2340cfb8d25e77066.zip |
Fix hostname settings in windows extended script (#659)v3.25.0
- if the hostname is set in the vm.args file, preserve it
- if it is not set, try to set it from env vars
- if the env vars are not set, leave it blank
Diffstat (limited to 'priv/templates/extended_bin_windows')
-rw-r--r-- | priv/templates/extended_bin_windows | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/priv/templates/extended_bin_windows b/priv/templates/extended_bin_windows index a8dfeb9..d30d78d 100644 --- a/priv/templates/extended_bin_windows +++ b/priv/templates/extended_bin_windows @@ -49,10 +49,28 @@ set node_name=%%J ) -@if "-sname" == "%node_type%" ( - set hostname="%COMPUTERNAME%" -) else ( - set hostname="%COMPUTERNAME%.%USERDNSDOMAIN% +@for /f "delims=@ tokens=1-2" %%I in ("%node_name%") do @( + set node_name=%%I + set hostname=%%J +) + +:: if no hostname is set, attempt to pick one from the env +@if "" == "%hostname%" @( + if "-sname" == "%node_type%" ( + if not "" == "%COMPUTERNAME%" ( + set "hostname=%COMPUTERNAME%" + ) + ) else ( + if not "" == "%COMPUTERNAME%" ( + if not "" == "%USERDNSDOMAIN%" ( + set "hostname=%COMPUTERNAME%.%USERDNSDOMAIN%" + ) + ) + ) +) +:: Add @ to hostname if not empty so that we can just concatenate values safely +@if not "" == "%hostname%" @( + set "hostname=@%hostname%" ) :: Extract cookie from vm.args @@ -199,7 +217,7 @@ set description=Erlang node %node_name% in %rootdir% set ERRORLEVEL=1 exit /b %ERRORLEVEL% ) -@%escript% "%rootdir%/bin/install_upgrade.escript" "install" "{'%rel_name%', \"%node_type%\", '%node_name%@%hostname%', '%cookie%'}" "%2" "%3" +@%escript% "%rootdir%/bin/install_upgrade.escript" "install" "{'%rel_name%', \"%node_type%\", '%node_name%%hostname%', '%cookie%'}" "%2" "%3" @goto :eof :: Start a console @@ -211,7 +229,7 @@ set description=Erlang node %node_name% in %rootdir% :: Ping the running node :ping -@%escript% %nodetool% ping %node_type% "%node_name%" -setcookie "%cookie%" +@%escript% %nodetool% ping %node_type% "%node_name%%hostname%" -setcookie "%cookie%" @goto :eof :: List installed Erlang services @@ -223,5 +241,5 @@ set description=Erlang node %node_name% in %rootdir% :attach @set boot=-boot "%clean_boot_script%" -boot_var RELEASE_DIR "%release_root_dir%" @start "%node_name% attach" %werl% %boot% ^ - -remsh %node_name%@%hostname% %node_type% console -setcookie %cookie% + -remsh %node_name%%hostname% %node_type% console -setcookie %cookie% @goto :eof |