Skip to content

Commit

Permalink
Merge branch 'premaster'
Browse files Browse the repository at this point in the history
  • Loading branch information
mfthomps committed Nov 27, 2023
2 parents e4d0e64 + 65fc390 commit 1748014
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ The installation script and the update-designer.sh script set environment variab
so you may want to logout/login, or start a new bash shell before using Labtainers the
first time.

November 27, 2023
- Add Google Cloud Platform option for ubuntu22 on ec2 machine.

September 18, 2023
- Previous fix implementation was flawed.

Expand Down
19 changes: 19 additions & 0 deletions google/base_create22.sh
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
3 changes: 2 additions & 1 deletion google/cloud_init.template
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ runcmd:
- docker pull labtainers/labtainer.wireshark2
- docker pull labtainers/labtainer.network.ssh2
- docker pull labtainers/labtainer.grader

- sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0 systemd.unified_cgroup_hierarchy=0"/' /etc/default/grub.d/50-cloudimg-settings.cfg
- update-grub
power_state:
mode: reboot
21 changes: 21 additions & 0 deletions google/create_vm_ec.sh
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
2 changes: 1 addition & 1 deletion google/publishImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# Only then run this script
#
#
gcloud compute images add-iam-policy-binding labtainervm5 \
gcloud compute images add-iam-policy-binding labtainervm6 \
--member='allAuthenticatedUsers' \
--role='roles/compute.imageUser'

0 comments on commit 1748014

Please sign in to comment.