Skip to content

Commit

Permalink
Merge pull request #6 from jmarhee/jmarhee/teardown
Browse files Browse the repository at this point in the history
Adds Makefile for smoothing ops, adds better teardown behavior native…
  • Loading branch information
jmarhee authored Nov 7, 2020
2 parents c2b246d + 05e64df commit 1532cd1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
4 changes: 4 additions & 0 deletions 03-tunnel-mgr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions scripts/proxy_status.sh
Original file line number Diff line number Diff line change
@@ -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 &
export -f connect_loop
nohup USER=${USER} HOST=${HOST} connect_loop &>/dev/null &
14 changes: 14 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
linode = {
source = "terraform-providers/linode"
}
null = {
source = "hashicorp/null"
}
random = {
source = "hashicorp/random"
}
}
required_version = ">= 0.13"
}

0 comments on commit 1532cd1

Please sign in to comment.