cloudfoundry-community / jumpbox-boshrelease

A BOSH release for jumpboxen
MIT License
22 stars 27 forks source link

check if we have internet connection before executing setup #57

Closed ramonskie closed 6 years ago

ramonskie commented 6 years ago

if a company does not allow exgress internet connection. we don't want to run the setup script and wait for it to timeout

ramonskie commented 6 years ago

the gpg key command timeout because the firewall will block the requests we can however check in the setup script if https://get.rvm.io is available instead?

jhunt commented 6 years ago
→  nc -v -z keyserver.ubuntu.com 80
Connection to keyserver.ubuntu.com port 80 [tcp/http] succeeded!

works for me. If the port is closed, and the remote host (or intervening firewall) is sending an RST to the SYN, it's almost immediate. Chances are, however, that any intervening firewall is actually going to silently drop the packet, which means you have to set a timeout on nc via -G:

→  nc -v -z -G 3 jameshunt.us 81
nc: connectx to jameshunt.us port 81 (tcp) failed: Operation timed out

(that takes about 3s to timeout, since jameshunt.us:81 just drops the packet without an RST)

You'll want to drop the -v in the script...