forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinworker.sh
executable file
·59 lines (52 loc) · 1.48 KB
/
winworker.sh
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
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${0}")/.."
source build/shlib.sh
export CLOUDSDK_CORE_PROJECT=${CLOUDSDK_CORE_PROJECT-${GCEWORKER_PROJECT-cockroach-workers}}
export CLOUDSDK_COMPUTE_ZONE=${GCEWORKER_ZONE-${CLOUDSDK_COMPUTE_ZONE-us-east1-b}}
NAME=${GCEWORKER_NAME-gceworker-win-$(id -un)}
cmd=${1-}
if [[ "${cmd}" ]]; then
shift
fi
reset_password() {
gcloud compute reset-windows-password --quiet "${NAME}"
cat <<EOF
You can now connect to this machine using Microsoft Remote Desktop.
EOF
}
case "${cmd}" in
create)
gcloud compute instances \
create "${NAME}" \
--machine-type "n1-standard-4" \
--network "default" \
--maintenance-policy "MIGRATE" \
--image-project "windows-cloud" \
--image-family "windows-2016" \
--boot-disk-size "100" \
--boot-disk-type "pd-ssd" \
--boot-disk-device-name "${NAME}" \
--scopes "default,cloud-platform"
retry reset_password
;;
start)
gcloud compute instances start "${NAME}"
;;
stop)
gcloud compute instances stop "${NAME}"
;;
delete|destroy)
gcloud compute instances delete "${NAME}"
;;
ip)
gcloud compute instances describe --format="value(networkInterfaces[0].accessConfigs[0].natIP)" "${NAME}"
;;
reset-password)
reset_password
;;
*)
echo "$0: unknown command: ${cmd}, use one of create, start, stop, delete, or reset-password"
exit 1
;;
esac