joaquim-verges/ProjectorAndroidStudio

Non Static IP script

Closed this issue · 2 comments

You might want to add a script for non static IP instance.
Should look like something like this:

#!/bin/bash

INSTANCE_ID=<your_instance_id>
PORT=8888
USER=root
REGION=<your_instance_region>

echo "Starting Server..."
aws ec2 start-instances --instance-ids $INSTANCE_ID
aws ec2 wait instance-running --instance-ids $INSTANCE_ID
echo "Server Started"
IP=`aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[*].Instances[*].PublicIpAddress' --output text`
EC2_IP=`echo $IP | sed 's/\./-/g'`

adb devices
ssh -o 'ConnectionAttempts 10' -i <your_pem_file_path> $USER@ec2-$EC2_IP.$REGION.compute.amazonaws.com "/home/$USER/.local/bin/projector run AndroidStudio" &
sleep 5
echo "Projector started, opening browser..."
google-chrome --new-window http://$IP:$PORT/
aws ec2 stop-instances --instance-ids $INSTANCE_ID
aws ec2 wait instance-stopped --instance-ids $INSTANCE_ID
echo "Done"

And no need for the config file

That's really handy! Made me realize that I forgot to mention how to get a static ip in the readme 😅 Thanks for pointing that out, I'll incorporate that in the script.