24 Commits
v1.0.2 ... main

Author SHA1 Message Date
140d1d803f added root-password-hashed 2025-06-26 19:08:10 -04:00
ef2ea6eedd remove cleartext root password from settings and history 2025-06-26 19:00:09 -04:00
b790be713a check for disk_list before removing 2024-10-12 20:33:00 -04:00
6809b34b9d Merge pull request #9 from Konrni/dev
use dropdown and add more descriptions
2024-10-07 21:22:13 -04:00
65bd553b09 enable arbitrary values for key selections 2024-10-07 10:51:13 -04:00
00fe5bf24c black 2024-10-07 10:30:04 -04:00
4b6cfeddad add descriptions from https://pve.proxmox.com/pve-docs/chapter-pve-installation.html#advanced_lvm_options
#advanced_lvm_options and https://pve.proxmox.com/wiki/Automated_Installation
2024-10-04 21:49:44 +02:00
6b0d81d4e9 use dropdown menu, when options are available. change FSelect to match FInput width 2024-10-02 22:18:13 +02:00
a3e07033e7 fixed stripping spaces for list values 2024-10-02 12:23:20 -04:00
5a3bb026d4 clean up 2024-10-01 21:16:16 -04:00
7aa752c3d3 improved list value handling 2024-10-01 21:14:53 -04:00
6b412140d4 Merge pull request #8 from Konrni/main
Add copy feature , fix a small bug
2024-09-30 21:37:35 -04:00
61157457b8 refactor answer selection actions 2024-09-29 17:36:37 -04:00
46cae312c8 Merge branch 'main' of https://github.com/Konrni/autopve 2024-09-29 19:16:12 +02:00
aa04718374 revert answer naming changes to allow submiting previous name 2024-09-28 16:46:32 -04:00
4c6495c4ee allow escape at answer naming 2024-09-28 16:45:48 -04:00
8f00ab9570 add password_toggle_button, enable password viewing 2024-09-28 10:34:30 +02:00
32dec36cd7 don't "unselect" after one answer deletion 2024-09-28 10:27:46 +02:00
f9b5c0d153 simplify answer storage logic and enable copy 2024-09-27 21:23:22 -04:00
b3dc60d950 improved answer sanity check 2024-09-27 21:21:47 -04:00
f8e93cedf2 syntax change 2024-09-27 21:20:30 -04:00
074975650f fix bug, where save after unchanged name would delete answer content 2024-09-28 00:01:29 +02:00
7f654071d0 added copy feature for answers 2024-09-27 23:51:13 +02:00
0711b55ad8 Update README.md 2024-05-12 15:01:46 -04:00
6 changed files with 133 additions and 49 deletions

View File

@ -2,7 +2,7 @@
## Demo
https://github.com/natankeddem/autopve/assets/44515217/7c766078-a69f-4dc3-889c-6d7113fd3421
https://github.com/natankeddem/autopve/assets/44515217/9439e2e2-a7bf-4677-aea8-0684318bea6c
## Information

View File

@ -44,6 +44,7 @@ class Drawer(object):
el.IButton(icon="add", on_click=self._display_answer_dialog)
self._buttons["remove"] = el.IButton(icon="remove", on_click=lambda: self._modify_answer("remove"))
self._buttons["edit"] = el.IButton(icon="edit", on_click=lambda: self._modify_answer("edit"))
self._buttons["content_copy"] = el.IButton(icon="content_copy", on_click=lambda: self._modify_answer("content_copy"))
ui.label(text="ANSWERS").classes("text-secondary")
self._table = (
ui.table(
@ -83,7 +84,7 @@ class Drawer(object):
self._table.add_rows({"name": name})
self._table.visible = True
async def _display_answer_dialog(self, name=""):
async def _display_answer_dialog(self, name="", copy=False):
save = None
with ui.dialog() as answer_dialog, el.Card():
@ -100,6 +101,8 @@ class Drawer(object):
def answer_check(value: str) -> Optional[bool]:
spaceless = value.replace(" ", "")
if len(spaceless) == 0:
return False
for invalid_value in all_answers:
if invalid_value == spaceless:
return False
@ -108,25 +111,28 @@ class Drawer(object):
def enter_submit(e: KeyEventArguments) -> None:
if e.key == "Enter" and save_ea.no_errors is True:
answer_dialog.submit("save")
elif e.key == "Escape":
answer_dialog.close()
answer_input = el.VInput(label="answer", value=" ", invalid_characters="""'`"$\\;&<>|(){}""", invalid_values=all_answers, check=answer_check, max_length=20)
save_ea = el.ErrorAggregator(answer_input)
el.DButton("SAVE", on_click=lambda: answer_dialog.submit("save")).bind_enabled_from(save_ea, "no_errors")
ui.keyboard(on_key=enter_submit, ignore=[])
answer_input.value = name
answer_input.value = name
result = await answer_dialog
if result == "save":
answer = answer_input.value.strip()
if len(answer) > 0 and name != "Default":
storage.answer(answer)
if name in storage.answers:
storage.answers[answer] = storage.answer(name, copy=True)
answer = answer_input.value.strip()
if result == "save" and name != answer:
if name in storage.answers:
storage.answers[answer] = storage.answer(name, copy=True)
if copy is False:
del storage.answers[name]
for row in self._table.rows:
if name == row["name"]:
self._table.remove_rows(row)
self._add_answer_to_table(answer)
for row in self._table.rows:
if name == row["name"]:
self._table.remove_rows(row)
else:
storage.answer(answer)
self._add_answer_to_table(answer)
def _modify_answer(self, mode):
self._hide_content()
@ -152,17 +158,20 @@ class Drawer(object):
async def _selected(self, e):
self._hide_content()
if self._selection_mode == "edit":
if len(e.selection) > 0 and e.selection[0]["name"] != "Default":
await self._display_answer_dialog(name=e.selection[0]["name"])
if self._selection_mode == "remove":
if len(e.selection) > 0:
for row in e.selection:
if row["name"] != "Default":
if row["name"] in storage.answers:
del storage.answers[row["name"]]
self._table.remove_rows(row)
self._modify_answer(None)
if len(e.selection) == 1:
answer = e.selection[0]["name"]
if self._selection_mode == "content_copy":
await self._display_answer_dialog(name=answer, copy=True)
self._modify_answer(None)
elif answer == "Default":
self._table._props["selected"] = []
elif self._selection_mode == "edit":
await self._display_answer_dialog(name=answer)
self._modify_answer(None)
elif self._selection_mode == "remove":
if answer in storage.answers:
del storage.answers[answer]
self._table.remove_rows(e.selection[0])
async def _clicked(self, e):
if "name" in e.args[1]:

View File

@ -364,7 +364,7 @@ class FSelect(ui.select):
clearable: bool = False,
) -> None:
super().__init__(options, label=label, value=value, on_change=on_change, with_input=with_input, new_value_mode=new_value_mode, multiple=multiple, clearable=clearable)
self.tailwind.width("64")
self.tailwind.width("[320px]")
class JsonEditor(ui.json_editor):

View File

@ -84,6 +84,15 @@ class History(Tab):
el.JsonEditor(properties=properties)
with ui.tab_panel(response_tab):
response = e.args["data"]["response"]
lines = response.splitlines()
response_lines = []
for line in lines:
if line.strip().startswith("root_password"):
response_lines.append('root_password = "SECRET"')
else:
response_lines.append(line)
response = "\n".join(response_lines)
ui.code(response).tailwind.height("[320px]").width("[640px]")
with el.WRow() as row:

View File

@ -51,16 +51,32 @@ class Setting(Tab):
key_row.tailwind.width("full").align_items("center").justify_content("between")
with ui.row() as row:
row.tailwind.align_items("center")
self._elements[key] = {
"control": el.FInput(
key,
if key in self.keys and "options" in self.keys[key]:
options = self.keys[key]["options"]
if value != "" and value not in self.keys[key]["options"]:
options.append(value)
control = el.FSelect(
label=key,
options=options,
with_input=True,
new_value_mode="add-unique",
on_change=lambda e, key=key: self.set_key(key, e.value) if e.value is not None else None,
)
else:
control = el.FInput(
label=key,
password=True if key == "root_password" else False,
autocomplete=self.keys[key]["options"] if key in self.keys and "options" in self.keys[key] else None,
password_toggle_button=False,
on_change=lambda e, key=key: self.set_key(key, e.value),
),
)
self._elements[key] = {
"control": control,
"row": key_row,
}
self._elements[key]["control"].value = value
if isinstance(control, el.FSelect):
control.value = self.keys[key]["options"][0] if value == "" else value
else:
control.value = value
if key in self.keys:
with ui.button(icon="help"):
ui.tooltip(self.keys[key]["description"])
@ -81,15 +97,17 @@ class Setting(Tab):
v: Any = ""
if len(value) > 0:
if key in self.keys and "type" in self.keys[key]:
if self.keys[key]["type"] == "list":
v = value[1:-1].split(",")
if self.keys[key]["type"] == "list" and len(value) > 2 and value.strip()[0] == "[" and value.strip()[-1] == "]":
l = value.strip()[1:-1].replace('"', "").replace("'", "").split(",")
v = [v.strip() for v in l]
elif self.keys[key]["type"] == "int":
v = int(value)
else:
v = value
else:
if len(value) > 2 and value.strip()[0] == "[" and value.strip()[-1] == "]":
v = value[1:-1].split(",")
l = value.strip()[1:-1].replace('"', "").replace("'", "").split(",")
v = [v.strip() for v in l]
elif value.isnumeric():
v = int(value)
else:
@ -109,12 +127,42 @@ class Setting(Tab):
class Global(Setting):
def __init__(self, answer: str) -> None:
keys = {
"keyboard": {"description": "The keyboard layout with the following possible options"},
"keyboard": {
"description": "The keyboard layout with the following possible options",
"options": [
"de",
"de-ch",
"dk",
"en-gb",
"en-us",
"es",
"fi",
"fr",
"fr-be",
"fr-ca",
"fr-ch",
"hu",
"is",
"it",
"jp",
"lt",
"mk",
"nl",
"no",
"pl",
"pt",
"pt-br",
"se",
"si",
"tr",
],
},
"country": {"description": "The country code in the two letter variant. For example, at, us or fr."},
"fqdn": {"description": "The fully qualified domain name of the host. The domain part will be used as the search domain."},
"mailto": {"description": "The default email address for the user root."},
"timezone": {"description": "The timezone in tzdata format. For example, Europe/Vienna or America/New_York."},
"root_password": {"description": "The password for the root user.", "type": "str"},
"root-password-hashed": {"description": "The pre-hashed password for the root user, which will be written verbatim to /etc/passwd. May be used instead of root_password and can be generated using the mkpasswd tool, for example.", "type": "str"},
"root_ssh_keys": {"description": "Optional. SSH public keys to add to the root users authorized_keys file after the installation."},
"reboot_on_error": {
"description": "If set to true, the installer will reboot automatically when an error is encountered. The default behavior is to wait to give the administrator a chance to investigate why the installation failed."
@ -126,7 +174,7 @@ class Global(Setting):
class Network(Setting):
def __init__(self, answer: str) -> None:
keys = {
"source": {"description": "Where to source the static network configuration from. This can be from-dhcp or from-answer."},
"source": {"description": "Where to source the static network configuration from. This can be from-dhcp or from-answer.", "options": ["from-dhcp", "from-answer"]},
"cidr": {"description": "The IP address in CIDR notation. For example, 192.168.1.10/24."},
"dns": {"description": "The IP address of the DNS server."},
"gateway": {"description": "The IP address of the default gateway."},
@ -149,19 +197,37 @@ class Disk(Setting):
"description": "The RAID level that should be used. Options are raid0, raid1, raid10, raidz-1, raidz-2, or raidz-3.",
"options": ["raid0", "raid1", "raid10", "raidz-1", "raidz-2", "raidz-3"],
},
"zfs.ashift": {"description": ""},
"zfs.arc_max": {"description": ""},
"zfs.checksum": {"description": ""},
"zfs.compress": {"description": ""},
"zfs.copies": {"description": ""},
"zfs.hdsize": {"description": ""},
"lvm.hdsize": {"description": ""},
"lvm.swapsize": {"description": ""},
"lvm.maxroot": {"description": ""},
"lvm.maxvz": {"description": ""},
"lvm.minfree": {"description": ""},
"zfs.ashift": {
"description": "Defines the ashift value for the created pool. The ashift needs to be set at least to the sector-size of the underlying disks (2 to the power of ashift is the sector-size), or any disk which might be put in the pool (for example the replacement of a defective disk)."
},
"zfs.arc_max": {
"description": "Defines the maximum size the ARC can grow to and thus limits the amount of memory ZFS will use. See also the section on how to limit ZFS memory usage for more details."
},
"zfs.checksum": {"description": "Defines which checksumming algorithm should be used for rpool."},
"zfs.compress": {"description": "Defines whether compression is enabled for rpool."},
"zfs.copies": {
"description": "Defines the copies parameter for rpool. Check the zfs(8) manpage for the semantics, and why this does not replace redundancy on disk-level."
},
"zfs.hdsize": {
"description": "Defines the total hard disk size to be used. This is useful to save free space on the hard disk(s) for further partitioning (for example to create a swap-partition). hdsize is only honored for bootable disks, that is only the first disk or mirror for RAID0, RAID1 or RAID10, and all disks in RAID-Z[123]."
},
"lvm.hdsize": {
"description": "Defines the total hard disk size to be used. This way you can reserve free space on the hard disk for further partitioning (for example for an additional PV and VG on the same hard disk that can be used for LVM storage)."
},
"lvm.swapsize": {
"description": "Defines the size of the swap volume. The default is the size of the installed memory, minimum 4 GB and maximum 8 GB. The resulting value cannot be greater than hdsize/8."
},
"lvm.maxroot": {
"description": "Defines the maximum size of the root volume, which stores the operation system. The maximum limit of the root volume size is hdsize/4."
},
"lvm.maxvz": {
"description": "Defines the maximum size of the data volume. The actual size of the data volume is: datasize = hdsize - rootsize - swapsize - minfree Where datasize cannot be bigger than maxvz."
},
"lvm.minfree": {
"description": "Defines the amount of free space that should be left in the LVM volume group pve. With more than 128GB storage available, the default is 16GB, otherwise hdsize/8 will be used."
},
"btrfs.raid": {
"description": "",
"description": "The RAID level that should be used. Options are raid0, raid1, and raid10",
"options": ["raid0", "raid1", "raid10"],
},
"btrfs.hdsize": {"description": ""},

View File

@ -102,7 +102,7 @@ async def post_answer(request: Request) -> PlainTextResponse:
if "network" in default_data and "network" in answer_data:
default_data["network"].update(answer_data["network"])
if "disk-setup" in default_data and "disk-setup" in answer_data:
if any("filter" in k for k in answer_data["disk-setup"]):
if any("filter" in k for k in answer_data["disk-setup"]) and "disk_list" in default_data["disk-setup"]:
del default_data["disk-setup"]["disk_list"]
if "disk_list" in answer_data["disk-setup"]:
for key in list(default_data["disk-setup"].keys()):