diff --git a/03-tunnel-mgr.tf b/03-tunnel-mgr.tf index f87b944..29b6831 100644 --- a/03-tunnel-mgr.tf +++ b/03-tunnel-mgr.tf @@ -29,6 +29,10 @@ resource "null_resource" "set_osx_proxy" { USER = var.ssh_user } } + provisioner "local-exec" { + when = "destroy" + command = "networksetup -setsocksfirewallproxystate wi-fi off" + } } resource "null_resource" "open_browser" { diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..507d199 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.SILENT: +tag-release: + if [[ $(TAG) == v?.?.? ]]; then echo "Tagging $(TAG)"; elif [[ $(TAG) == v?.?.?? ]]; then echo "Tagging $(TAG)"; else echo "Bad Tag Format: $(TAG)"; exit 1; fi && git tag -a $(TAG) -m "Releasing $(TAG)" ; read -p "Push tag: $(TAG)? " push_tag ; if [ "${push_tag}"="yes" ]; then git push self $(TAG); fi + +proxy-up: + terraform apply -auto-approve + +proxy-down: + terraform destroy -auto-approve + +proxy-test: + curl http://ipinfo.io/json + +mac-proxy-down: + networksetup -setsocksfirewallproxystate wi-fi off + diff --git a/README.md b/README.md index 1493239..b9ef681 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,12 @@ in order to proxy through xx.xx.xx.xx This latter address will be your host address on Linode, which you can check to confirm is online and troubleshoot connectivity further. +If, on OS X, the node launches properly and there is an `ssh` process active, but you have not been connected to the proxy, run: + +```bash +USER=root HOST=${output_host_ip} scripts/proxy_status.sh +``` + If you are on OS X, and after `destroy`, you are receiving an error indicating the proxy is no longer available, you may need to manually deconfigure the proxy configuration by running: ```bash diff --git a/scripts/proxy_status.sh b/scripts/proxy_status.sh index 3c8e3a5..b22011e 100755 --- a/scripts/proxy_status.sh +++ b/scripts/proxy_status.sh @@ -1,18 +1,9 @@ #!/bin/bash -proxy_status () { - - while true; do \ - if [ "$(ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q ${USER}@${HOST} exit ; echo $?)" = "0" ]; then \ - sleep 5; continue - else - networksetup -setsocksfirewallproxystate wi-fi off - break - fi - done - +connect_loop () { + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q ${USER}@${HOST} "while true; do sleep 30; done" ; networksetup -setsocksfirewallproxy wi-fi 127.0.0.1 8888 } networksetup -setsocksfirewallproxy wi-fi 127.0.0.1 8888 -export -f proxy_status -nohup USER=${USER} HOST=${HOST} proxy_status &>/dev/null & \ No newline at end of file +export -f connect_loop +nohup USER=${USER} HOST=${HOST} connect_loop &>/dev/null & diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..9aae492 --- /dev/null +++ b/versions.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + linode = { + source = "terraform-providers/linode" + } + null = { + source = "hashicorp/null" + } + random = { + source = "hashicorp/random" + } + } + required_version = ">= 0.13" +}