-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
if [ "$#" -ne 1 ]; then | ||
echo "create_vm.sh <user ID>" | ||
exit | ||
fi | ||
user_id=$1 | ||
vm_name=$user_id-labtainervm | ||
cp cloud_init.template cloud_init.txt | ||
gcloud compute instances create $vm_name --image-family=ubuntu-2204-lts \ | ||
--machine-type=e2-standard-2 \ | ||
--image-project=ubuntu-os-cloud \ | ||
--metadata-from-file=user-data=cloud_init.txt | ||
echo "wait 40 seconds" | ||
sleep 40 | ||
gcloud compute ssh labtainer@$vm_name --command='echo "VM created, wait for reboot"' || exit | ||
cp ~/.ssh/google_compute_engine ~/.ssh/id_labtainers | ||
cp ~/.ssh/google_compute_engine.pub ~/.ssh/id_labtainers.pub | ||
echo "Now wait until up." | ||
./waitdone.sh $user_id |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
# | ||
# Create a Labtainers VM using the public Labtainers VM | ||
# | ||
if [ "$#" -ne 1 ]; then | ||
echo "create_vm.sh <user ID>" | ||
exit | ||
fi | ||
user_id=$1 | ||
vm_name=$user_id-labtainervm | ||
zone=$(./findzone.sh) | ||
gcloud compute instances create $vm_name --image=https://www.googleapis.com/compute/v1/projects/labtainers/global/images/labtainervm6 \ | ||
--metadata-from-file=user-data=user_config.txt --zone=$zone | ||
gcloud compute disks resize $vm_name --size 30G --zone=$zone -q | ||
# instances fail ssh until settled | ||
./waitup.sh $user_id 2>/dev/null | ||
echo "Check keys" | ||
gcloud compute ssh labtainer@$vm_name --command="echo VM booted" --zone=$zone | ||
cp ~/.ssh/google_compute_engine ~/.ssh/id_labtainers | ||
cp ~/.ssh/google_compute_engine.pub ~/.ssh/id_labtainers.pub | ||
./waitdone.sh $user_id |
This file contains 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