-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tunnel_aws_server.command
More file actions
executable file
·36 lines (31 loc) · 1.66 KB
/
Copy pathrun_tunnel_aws_server.command
File metadata and controls
executable file
·36 lines (31 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
aws ec2 start-instances --instance-ids i-0193a1e01f23aca23
the_ip=$(aws ec2 describe-instances | python -c "import sys, json; print json.load(sys.stdin)['Reservations'][0]['Instances'][0]['PublicIpAddress']")
echo this is an echo of aws server ip $the_ip
code=$(aws ec2 describe-instances | python -c "import sys, json; print json.load(sys.stdin)['Reservations'][0]['Instances'][0]['State']['Name']")
echo the AWS instance is $code
while [ $code != "running" ]; do
code=$(aws ec2 describe-instances | python -c "import sys, json; print json.load(sys.stdin)['Reservations'][0]['Instances'][0]['State']['Name']")
echo the AWS instance is $code
sleep 5
done
code=$(aws ec2 describe-instance-status | python -c "import sys, json; print json.load(sys.stdin)['InstanceStatuses'][0]['SystemStatus']['Status']")
while [ $code != "ok" ]; do
code=$(aws ec2 describe-instance-status | python -c "import sys, json; print json.load(sys.stdin)['InstanceStatuses'][0]['SystemStatus']['Status']")
echo the AWS instance is $code
sleep 5
done
echo start ssh tunnal
sudo killall -HUP mDNSResponder #clear all DNS
ssh -i ~/.ssh/ronnewvm.pem -o StrictHostKeyChecking=no -D 8123 -C -q -N -o ConnectTimeout=120 ubuntu@$the_ip &
echo tunnal open
echo set proxy config
sudo networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 8123 ;
sleep 5
#/usr/bin/open -W -a "/Applications/Google Chrome.app" "https://www.netflix.com/browse"
/usr/bin/open -W -a "/Applications/Firefox.app" "https://www.netflix.com/browse"
echo app open
pkill ssh
sudo networksetup -setsocksfirewallproxystate Wi-Fi off
echo end tunnal to AWS server
aws ec2 stop-instances --instance-ids i-0193a1e01f23aca23