Last active
February 11, 2018 06:10
-
-
Save benkant/79c5eaf5af40a425934b8104ad483ded to your computer and use it in GitHub Desktop.
spacewindows.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# TODO check we are on macOS | |
# TODO https://google.github.io/styleguide/shell.xml | |
INSTANCE_NAME=$INSTANCE_NAME | |
gcloud compute instances start $INSTANCE_NAME | |
IPADDRESS=`gcloud compute instances describe $INSTANCE_NAME | grep natIP | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])'` | |
printf "%s is at %s\n" $INSTANCE_NAME $IPADDRESS | |
# TODO check Microsoft RDP is installed | |
MS_RD_DB="$HOME/Library/Containers/com.microsoft.rdc.macos/Data/Library/Application Support/com.microsoft.rdc.macos/com.microsoft.rdc.application-data.sqlite" | |
UPDATE_STMT="update ZBOOKMARKENTITY set ZHOSTNAME = '$IPADDRESS' where ZFRIENDLYNAME = '$INSTANCE_NAME';" | |
sqlite3 "$MS_RD_DB" "$UPDATE_STMT" | |
# TODO wait for the instance to be ready to connect to | |
# TODO damn certificates (to the tune of Lou in car chase: "Damn boxes".) | |
open -a "Microsoft Remote Desktop" | |
read -p "Press return key to shutdown... " | |
gcloud compute instances stop $INSTANCE_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment