-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathMakefile
165 lines (136 loc) · 7.37 KB
/
Makefile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
EXEC=${VAULT_EXEC}
TF_DIR=terraform
# Create the project dirs
dirs:
mkdir -p tmp
mkdir -p state
# initialize the terraform project
# this will also download the providers needed
init: dirs
terraform init
# run a terraform plan
plan:
$(EXEC) terraform plan -state=state/terraform.tfstate -out=tmp/tf-plan $(TF_DIR)
# run a terraform apply using the plan you just created
apply:
$(EXEC) terraform apply -state=state/terraform.tfstate tmp/tf-plan
# refresh the terraform state , just in case
refresh:
$(EXEC) terraform refresh -state=state/terraform.tfstate $(TF_DIR)
# Place holder for the syntax on how to import an existing resource in the terraform state
import:
$(EXEC) terraform import -config=$(TF_DIR) -state=state/terraform.tfstate aws_iam_instance_profile.windows_instance_profile cloud-gaming-instance-profile
# Formats terraform files
fmt:
terraform fmt
# Show the terrform output variabls
output:
terraform output -state=state/terraform.tfstate
# Like vagrant up , do a plan , apply and provision
up: plan apply provision
# Remove your terraform setup
destroy:
$(EXEC) terraform destroy -state=state/terraform.tfstate $(TF_DIR)
# Write your vm ip in a tempory file for easy access
# This allows us to run ssh scripts without having to run terraform output everytime
ip:
terraform output -state=state/terraform.tfstate instance_ip > tmp/ip
# -t to make tab completion work
# stricthost to ignore keys everytime
# TODO : assumes your ssh key is loaded
ssh: ip
ssh -t -o "StrictHostKeyChecking no" Administrator@$(shell cat tmp/ip) powershell
# Blindly trusts the ssh key from your remote vm/ip and updates your known_hosts
trust:
ssh-keygen -R $(shell cat tmp/ip)
ssh-keyscan -H $(shell cat tmp/ip) >> ~/.ssh/known_hosts
# Transfers your powershell script to the vm
sync: ip
scp -r powershell/*.ps1 Administrator@$(shell cat tmp/ip):/scripts/
scp -r powershell/*.txt Administrator@$(shell cat tmp/ip):/scripts/
scp -r powershell/*.au3 Administrator@$(shell cat tmp/ip):/scripts/
scp -r powershell/*.bat Administrator@$(shell cat tmp/ip):/scripts/
# WIP: use rsync instead of sync to make it faster
# TODO: figure out to get rsync working on the windows side
#rsync:
# rsync -avz --rsync-path=/ProgramData/chocolatey/bin/rsync.exe powershell/*.ps1 Administrator@$(shell cat tmp/ip):/scripts/
# Runs the hello world script to see if it is working
hello: ip trust sync
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\hello.ps1'
# Provision all steps
# TODO: make this more granular
# Make it stop on error
base:
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\chocolatey.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\7zip-install.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\ie-security.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\googlechrome.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\nvidia.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\nvidia-faceworks-demo.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\aws-desktop-cleanup.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\aws-tools.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\aws-cli.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\nice-dcv.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\set-time-timezone.ps1'
# Restart to get the video driver good
#ssh -t Administrator@$(shell cat tmp/ip) 'shutdown /r /t 10 /d p:4:1 /c \"gamer Restart\"'
reboot:
ssh -t Administrator@$(shell cat tmp/ip) 'shutdown /r /t 10 /d p:4:1 /c \"gamer Restart\"'
pixel:
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\pixelstreaming.ps1'
obs:
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\obs.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\autoit.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\unix.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\aws-vault.ps1'
# needs reboot
ndi:
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\newtek-unreal-ndi.ps1'
zoom: base obs ndi pixel
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\zoom.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'shutdown /r /t 10 /d p:4:1 /c \"gamer Restart\"'
provision:
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\chocolatey.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\7zip-install.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\audio-razer.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\install-directx.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\dot-net-core.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\directplay.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\enable-mousekeys.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\pointer-precision.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\aws-desktop-cleanup.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\aws-tools.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\googlechrome.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\set-time-timezone.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\server-manager.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\ie-security.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\nvidia.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\nvidia-faceworks-demo.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\devcon.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\xbox360-controller.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\disable-devices.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\parsec.ps1'
ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\vigembus.ps1'
#ssh -t Administrator@$(shell cat tmp/ip) 'powershell -File C:\scripts\steam.ps1'
# Caches the admin password for easy access
password:
terraform output -state=state/terraform.tfstate Administrator_Password > tmp/password
# Creates an rdp shortcut to the instance
# And populates the password in our copy & paste buffer
# Note: windows remote desktop on mac does not allow for passwords in the rdp file
# TODO: other rdp clients might solve this
rdp:
echo "auto connect:i:1" > tmp/vm.rdp
echo "full address:s:$(shell cat tmp/ip)" >> tmp/vm.rdp
echo "username:s:Administrator" >> tmp/vm.rdp
cat tmp/password | tr -d '\n' | pbcopy
open tmp/vm.rdp
# https://github.com/awsdocs/nice-dcv-user-guide/blob/master/doc_source/using-connection-file.md#connection-file-params
dcv:
echo "[version]" > tmp/vm.dcv
echo "format=1.0" >> tmp/vm.dcv
echo "[connect]" >> tmp/vm.dcv
echo "host=$(shell cat tmp/ip)" >> tmp/vm.dcv
echo "user=Administrator" >> tmp/vm.dcv
echo "password=$(shell cat tmp/password | tr -d '\n')" >> tmp/vm.dcv
/Applications/DCV\ Viewer.app/Contents/MacOS/dcvviewer tmp/vm.dcv >/dev/null