Skip to content

Instantly share code, notes, and snippets.

@jaredmales
Last active February 1, 2025 02:30
Show Gist options
  • Save jaredmales/f7d9070ebc23e153966f03b8477102fc to your computer and use it in GitHub Desktop.
Save jaredmales/f7d9070ebc23e153966f03b8477102fc to your computer and use it in GitHub Desktop.
perform an unattended multipass VM setup and provisioning for MagAO-X
#!/bin/bash
#################################################################################
# perform an unattended multipass VM setup and provisioning for MagAO-X
#
# note that you need ~/.ssh/id_ed25519.pub
#
# todo: provide CLI option to change name.
# todo: provide CLI options to change disk/cpus/memory
#
################################################################################
#basic VM creation
multipass launch -n magao-x-vm -c 4 -d 20GiB -m 8.0GiB 24.04
multipass mount $HOME magao-x-vm:/home/ubuntu/Home
#install our key
multipass exec magao-x-vm -- bash -c "echo `cat ~/.ssh/id_ed25519.pub` >> ~/.ssh/authorized_keys"
# first ssh needs to force acceptance of the host key
ssh -o StrictHostKeyChecking=accept-new ubuntu@$(multipass exec magao-x-vm -- hostname -I | awk '{ print $1 }' ) "sudo apt update && sudo apt upgrade -y"
#apply the updates
multipass stop magao-x-vm
multipass start magao-x-vm
#get MagAO-X repo
ssh ubuntu@$(multipass exec magao-x-vm -- hostname -I | awk '{ print $1 }' ) "git clone --depth=1 https://github.com/magao-x/MagAOX.git"
#pre_provision as workstation to setup environment and users & groups
ssh ubuntu@$(multipass exec magao-x-vm -- hostname -I | awk '{ print $1 }' ) "cd MagAOX/setup && MAGAOX_ROLE=workstation ./pre_provision.sh"
#this must be a separate login to get groups updated
ssh ubuntu@$(multipass exec magao-x-vm -- hostname -I | awk '{ print $1 }' ) "cd MagAOX/setup && bash ./provision.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment