Compare commits

..

7 commits

Author SHA1 Message Date
aryan e8c064ae9a add argparse flags for ram and port specification 2024-09-04 12:46:31 -06:00
aryan 89c67eaf62 update os to getpass 2024-09-04 12:31:01 -06:00
aryan 2cb1587b23 clean up` 2024-09-04 12:27:56 -06:00
aryan 4b2ab6794c made function and added nographic flag 2024-08-21 19:35:32 -06:00
aryan 5e94d00a5c build script update 2024-08-17 17:22:29 -06:00
aryan c0f174f551 basic working build script 2024-08-17 17:07:48 -06:00
aryan 7c818dd926 started some stuff 2024-08-17 15:17:14 -06:00

View file

@ -1,3 +1,44 @@
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import getpass
from pathlib import Path
import argparse
print("meow") def vm_start(nographic=False):
home = Path.home()
user = getpass.getuser()
image_src = "var/lib/debian.qcow2"
vm_storage_location = f"/home/arvp/virtual_machines/{user}.qcow2"
image_dest = f"{home}/debian.qcow2"
initialize = [
"qemu-system-x86_64",
"-enable-kvm",
"-m", RAM, # ram allocation
"-nic", f'user,hostfwd=tcp::{PORT}-:22', #forward port 5555 in host to port 22 in vm
"-drive", "file=%s,media=disk,if=virtio" % image_dest,
]
if nographic:
initialize.append("-nographic")
initialize.append("-serial")
initialize.append("mon:stdio")
else:
initialize.append("-vga")
initialize.append("virtio")
initialize.append("-display")
initialize.append("sdl")
#copy the base image to a directory with everyones virtual machines. -n should not overwrite any existing vms.
#subprocess.run(["cp", "-n", image_src, vm_storage_location])
Popen(initialize)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="ARVP Onboarding Virtual Machine Launcher! Don't use --nographic if you are in a tmux session. it might explode :3")
parser.add_argument(
"-nographic",
action="store_true",
help="Run QEMU in nographic mode (runs the VM embedded in your terminal instead of opening a new window)",)
parser.add_argument("-port", help="Port to forward to the VM for ssh", default=5555)
parser.add_argument("-ram", help="Amount of RAM to allocate to the VM", default="4G")
args = parser.parse_args()
vm_start(nographic=args.nographic)