Commit Graph

47 Commits

Author SHA1 Message Date
Christoph Heiss
a1575df428 tree-wide: rust: run cargo fmt
The 2024 style guide changed some things, which causes quite some churn. Most of
boils down to the changed import order, now choosing types before function
items - which is the other way round then before.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-02-28 16:04:40 +01:00
Christoph Heiss
c305be5e91 tree-wide: rust: update to 2024 edition
Updates (and unifies) the edition across the workspace to 2024.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-02-28 16:04:40 +01:00
Christoph Heiss
97c12b5493 tree-wide: add workspace-level cargo package version
Means that all CLIs will now have the correct version compiled-in.

This is at least very much relevant for
`proxmox-auto-install-assistant`, which we distribute separately as a
normal binary/package.

Currently, `proxmox-auto-install-assistant --version` always reports
'0.1.0', thus users have to effectively fall back to their system
package manager (if installed via such) to identify the correct version.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-01-28 15:31:00 +01:00
Christoph Heiss
8ea891cd81 assistant: validate answer first-boot hook and locale settings
For the first-boot hook, the check from the auto-installer can be easily
re-used.

For the locale, as we now have that information available as JSON,
include that file in the assistant and use it to verify the answer file
settings.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-12-10 18:00:24 +01:00
Christoph Heiss
8341108e18 fix #5889: assistant: validate answer email & root password settings
These checks are basically "free" and can be re-used from the
auto-installer 1:1.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-12-10 18:00:24 +01:00
Christoph Heiss
684bbaa2b9 tree-wide: fix rustdoc warnings
Mostly URLs, which need to be surrounded by < > to be properly
formatted.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-12-03 18:16:05 +01:00
Christoph Heiss
965abf2dc2 fix #5579: auto-install-assistant: enable baking in first-boot script
Adds a new parameter `--on-first-boot` to the `prepare-iso` command, to
specify a file to bake into the ISO.

To later use it with the auto-installer, the following must be set in
the answer file:

  [first-boot]
  source = "from-iso"

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-18 22:29:23 +01:00
Christoph Heiss
ec7b808c2e assistant: avoid regex for simple prefix matching
udev properties are very easy to parse and can be done by doing a
line-based scan and matching the prefix, splitting once for properties.
Avoids the use of regexes and signicantly reduces binary size by about
-46%(!).

Tested by comparing the output of `proxmox-auto-install-assistant
device-info`, running it before and after the changes.

Stripped binary size for release builds:

  before: 3869304 bytes ~ 3.69MiB
  after:  2091608 bytes ~ 1.99MiB

   text    data     bss     dec     hex filename
3580692  280920     545 3862157  3aee8d assistant-before
2031252   52336     505 2084093  1fccfd assistant-after

No functional changes.

Reviewed-By: Aaron Lauterer <a.lauterer@proxmox.com>
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-14 20:52:21 +01:00
Christoph Heiss
687aa6772b tree-wide: run rustfmt, fix clippy warnings
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-14 20:52:18 +01:00
Christoph Heiss
a25e5715eb assistant: pre-compile ignored block device patterns
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-By: Aaron Lauterer <a.lauterer@proxmox.com>
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
2024-11-12 20:55:21 +01:00
Christoph Heiss
4e09f2be0d auto-install-assistant: replace PathBuf parameters with AsRef<Path>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-11 18:20:19 +01:00
Christoph Heiss
7a8d69c1e5 tree-wide: convert some more crates to use workspace dependencies
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-11 18:20:19 +01:00
Christoph Heiss
6cabb2f1d0 tree-wide: fix some typos
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:26:11 +01:00
Christoph Heiss
2fdf22a8ba fetch-answer: use partition label from fetch config instead of hardcoded
This has been requested by at least one user one user [0] and definitely
makes sense, esp. for BMCs/IPMIs where one might not be able to control
the partition label.

[0] https://forum.proxmox.com/threads/proxmox-ais-question-request.153043/post-695689

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-By: Aaron Lauterer <a.lauterer@proxmox.com>
2024-11-10 19:22:19 +01:00
Christoph Heiss
2e89c07c4e auto-install-assistant: add new parameter to specify partition label
.. for the 'partition' fetch method.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-By: Aaron Lauterer <a.lauterer@proxmox.com>
2024-11-10 19:22:08 +01:00
Christoph Heiss
45a064e661 cargo: convert anyhow to workspace dependency
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-10 19:17:07 +01:00
Christoph Heiss
25a6121b27 debian: bump toml to 0.8
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-08-13 13:07:36 +02:00
Aaron Lauterer
af1de9e5f1 assistant: use single dash for xorriso parameter
while it works with two, one is what is shown in the man page and what
we already use for the other paramters.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2024-05-08 15:50:42 +02:00
Aaron Lauterer
1a01a018b9 assistant: keep prepared iso bootable on uefi with flash drives
By mapping files into the ISO, the UUID for the partitions change as
they depend on the timestamp. The result is, that grub cannot find its
partition anymore and the user ends up on the grub shell.

This only happens when booting from a blockdev in UEFI mode. E.g. a USB
flash drive. Alternatively one can `dd` the ISO to a small (2GiB) VM
disk and mark it as the first boot device.

When booting in legacy mode or via CDROM (e.g. pass through via IPMI),
it worked.

Xorriso can report the commands needed to recreate the source ISO. The
'-volume_date uuid' is the one needed to override the same UUIDs. We
therefore read it first from the source iso and pass it as parameter
whenever we inject a file into the iso.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2024-05-08 15:50:42 +02:00
Alexander Zeidler
13eea62e03 assistant: fix spelling and precise text in help usage output
Signed-off-by: Alexander Zeidler <a.zeidler@proxmox.com>
2024-04-25 17:52:58 +02:00
Thomas Lamprecht
6b747eb89e assistant: updated remaining error messages to reworked CLI
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 11:27:56 +02:00
Dominik Csapak
f277a4087e assistant: fix newline before ':' in help usage output
this belongs after the ':' otherwise the output looks weird:

  [..] can be
  : * integrated into [..]
  * needs to be [..]

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 11:27:56 +02:00
Thomas Lamprecht
07fc7803cf auto-installer: shorten partition label to fit in 11 characters for FAT
(v)FAT is still the most popular FS on removable medias like USB pen
drives, so we need to cope with its legacy..

So, rename the label that we look for again to PROXMOX-AIS, as that
still should allow admins to better recognize what this might be for
by having the "Proxmox" context and the rest is just hard to get
sensible meaning in, so do not bother to invent elaborate explanations
of why AIS is a good choice, it isn't but it's about the best thing
that one can do in these constraints.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 11:27:56 +02:00
Thomas Lamprecht
9573116251 assistant: collapse nested if
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 20:50:06 +02:00
Thomas Lamprecht
3715f3ccbe assistant: fix mentioning outdated fetch-from mode in error
... and unify the branches for non-http mode.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 18:26:57 +02:00
Thomas Lamprecht
34dd7bcf7f assistant: rework prepare-iso doc comment to recent changes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 18:26:20 +02:00
Alexander Zeidler
c08668b5d6 assistant: prepare iso: s/direct/included to match current naming
Signed-off-by: Alexander Zeidler <a.zeidler@proxmox.com>
2024-04-23 17:27:17 +02:00
Thomas Lamprecht
57ca9622ca run cargo fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 16:08:43 +02:00
Thomas Lamprecht
c8160a3f1c auto installer: rename fetch mode type and included variant
This is not a installation mode but rather tells us where to fetch the
answer file from.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 15:18:18 +02:00
Thomas Lamprecht
c022970458 auto installer: rework the default filename suffix addded to the prepared iso
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 15:18:18 +02:00
Thomas Lamprecht
4cf15bd163 auto installer: fetch mode: move http settings into own struct
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 15:18:18 +02:00
Thomas Lamprecht
11f2e83f4c assistant: default to output directory for tmp iso file on prepare
The directory where the input ISO is on might be read-only and so it
makes more sense to use the output directory to derive the default tmp
directory from.

Note that by default the output directory is the same as the one from
the input file, so this commit won't have a change for those that do
not override the output file explicitly.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 15:18:18 +02:00
Thomas Lamprecht
9aa27fa455 assistant: rework prepare-iso command line interface
Use input and output for the input and output files, drop various
short options, we can always re-add them later and forcing the use of
the more telling long options is a UX gift to sites with multiple
admins working on this stuff.

Further rename the "install-mode" to "fetch-from" as the option does
not changes the installation mode but rather the mode where the answer
file is fetched from.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 15:18:18 +02:00
Thomas Lamprecht
1470045272 auto installer: drop fetch-from auto mode
It simpler to force the user to chose, as then they will always know
where an ISO pulls the answer file from without any complex automatic
fallback logic, which might be also undesired, especially in
environments where one has not full control (trust) over the network.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 15:18:15 +02:00
Thomas Lamprecht
d2c9b9fda4 make auto install source mode use a singular name
A enum is always only one specific variant, not multiple.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 15:18:15 +02:00
Wolfgang Bumiller
810c860dba cargo clippy --fix
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-23 10:02:39 +02:00
Wolfgang Bumiller
2a77784149 cleanup unnecessary clones
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-23 10:02:39 +02:00
Wolfgang Bumiller
a7edd237e6 less strict regex for matching udev env variables
looking through /usr/lib/udev/rules.d there are at least some which
also have digits (eg. `IEEE1394_...`), so let's just match [^=]+ for
the variable name.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-23 10:02:39 +02:00
Thomas Lamprecht
938726d500 assistant: prepare iso: avoid an useless intermediate copy of the answer file
This fixes a bug for the case where the answer file was named
"answer.toml", as then the code tried to copy the file to itself,
which just caused the file being truncated.

This was quite confusing for the user, as the validation of the answer
file happened before the copy step, so one would see that it got
correctly validated only to then turn up empty inside the ISO..

While this was introduced through a14a934 ("assistant: perpare-iso
avoid separate directory and make less verbose"), copying the answer
file before injecting it into the ISO was never required, so just use
the source file directly.

Note that this is still a bit racy w.r.t. validation and inserting
into the ISO, to fix that we'd need to pass around empty files or
write the content directly, both not worth it for now.

Fixes: a14a934
Reported-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 16:51:42 +02:00
Thomas Lamprecht
ca8b8ace70 assistant: improve check if xorriso is installed
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00
Thomas Lamprecht
0a733567a2 assistant: rename identifiers command to system-info
better fits to what it does and to the device-info sibling command.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00
Thomas Lamprecht
d4c43e9df8 assistant: rustify getting sysinfo
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00
Thomas Lamprecht
f59910ebf1 print paths directly with debug, not display
A debug print is not only shorter code but also quotes the path
correctly, making it nicer for the user to copy (e.g., if the path is
at the end of a sentence the trailing dot could be misinterpreted as
being part of the path otherwise)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00
Thomas Lamprecht
a14a9348f2 assistant: perpare-iso avoid separate directory and make less verbose
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00
Thomas Lamprecht
528d126876 fetch answers: rename partition search label
The new one is far from perfect either, but labels can be at max 16
characters, so that's what we have to work with.

It now is slightly easier to read due to the hyphen separation and
contains the following relevant info:
- proxmox spelled out in full, so anybody seeing that label has a good
  chance to narrow down what it could do already by a lot
- inst is a bit cryptic, but that Proxmox has a installer is a easy to
  find out fact
- src should hopefully relay that this is the source of
  (configuration) for something related to a installer by proxmox

But yeah, please don't limit IDs or names to less than 32, ideally
even 64, characters, that's the bare minimum to get some expressive
names that can have actual meaning..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00
Thomas Lamprecht
95be2375e4 auto install: fine tune flag/config file names on ISO
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00
Thomas Lamprecht
2721bd70eb rename proxmox-autoinst-helper to proxmox-auto-install-assistant
stay on the verbose side

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 14:31:37 +02:00