1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/python3
import os
import pathlib
import subprocess
INSTANCE_NAME="workstation-test"
USER="alex"
THIS_REPO = pathlib.Path(__file__).parent.parent
THIS_UID = os.getuid()
def _(*args, check=True, input=None):
return subprocess.run(args, check=check, input=input, text=True)
# _("incus", "launch",
# "images:debian/13",
# INSTANCE_NAME,
# "--ephemeral",
# "--vm",
# "-c", "limits.cpu=4",
# "-c", "limits.memory=6GiB",
# "-d", "root,size=50GiB")
# while _("incus", "exec", INSTANCE_NAME, "uptime", check=False).returncode != 0:
# print("waiting...")
# time.sleep(1)
# _("incus", "config", "device", "add", INSTANCE_NAME, "here", "disk", f"source={THIS_REPO}", "path=/here")
# _("incus", "exec", INSTANCE_NAME, "--", "apt", "full-upgrade", "-U")
# _("incus", "exec", INSTANCE_NAME, "--", "apt", "install", "-y", "python3")
# _("incus", "exec", INSTANCE_NAME, "--", "/here/workstation/root-setup.py")
# _("incus", "exec", INSTANCE_NAME, "--", "adduser", USER, "--disabled-password", "--comment", "")
# _("incus", "exec", INSTANCE_NAME, "--", "passwd", USER, "--stdin", input=USER)
# Comment out to test with real repo
_("incus", "exec", INSTANCE_NAME, "--", "mount", "/here/", f"/home/{USER}/git/alexpdp7/", "-o", f"bind,X-mount.idmap={THIS_UID}:1000:1")
_("incus", "exec", INSTANCE_NAME, "--", "sudo", "-u", USER, "/here/workstation/user-setup.py")
|