WIP:aryan/build #1
44
build.py
44
build.py
|
@ -1,3 +1,45 @@
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|||||||
print("meow")
|
def vm_start(nographic=False):
|
||||||
|
home = Path.home()
|
||||||
|
user = os.getlogin()
|
||||||
|
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", "2G", # ram allocation
|
||||||
akemi
commented
This list and the corresponding popen should be in a function that accepts an argument to toggle those nographic flags This list and the corresponding popen should be in a function that accepts an argument to toggle those nographic flags
|
|||||||
|
"-nic", "user,hostfwd=tcp::5555-:22", #forward port 5555 in host to port 22 in vm
|
||||||
|
"-drive", "file=%s,media=disk,if=virtio" % image_dest,
|
||||||
|
|
||||||
|
# "-nographic",
|
||||||
|
# "-serial", "mon:stdio",
|
||||||
|
|
||||||
|
"-vga", "virtio", # i think this fixes resolution but idk yet
|
||||||
|
"-display", "sdl",
|
||||||
|
]
|
||||||
|
|
||||||
|
if nographic==True:
|
||||||
|
initialize.append("-nographic")
|
||||||
|
initialize.append("-serial")
|
||||||
|
initialize.append("mon:stdio")
|
||||||
|
|
||||||
|
#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)",)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
vm_start(nographic=args.nographic)
|
||||||
|
|
Loading…
Reference in a new issue
Might be better to use
Path.home()
from pathlib. Probably just leave it in the home directory, since safe doesn't necessarily exist for new users