mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-04-28 10:32:12 +00:00
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>
This commit is contained in:
parent
8341108e18
commit
8ea891cd81
@ -15,14 +15,18 @@ use proxmox_auto_installer::{
|
||||
sysinfo::SysInfo,
|
||||
utils::{
|
||||
get_matched_udev_indexes, get_nic_list, get_single_udev_index,
|
||||
verify_email_and_root_password_settings, AutoInstSettings,
|
||||
FetchAnswerFrom, HttpOptions,
|
||||
verify_email_and_root_password_settings, verify_first_boot_settings,
|
||||
verify_locale_settings, AutoInstSettings, FetchAnswerFrom, HttpOptions,
|
||||
},
|
||||
};
|
||||
use proxmox_installer_common::{FIRST_BOOT_EXEC_MAX_SIZE, FIRST_BOOT_EXEC_NAME};
|
||||
|
||||
static PROXMOX_ISO_FLAG: &str = "/auto-installer-capable";
|
||||
|
||||
/// Locale information as raw JSON, can be parsed into a
|
||||
/// [LocaleInfo](`proxmox_installer_common::setup::LocaleInfo`) struct.
|
||||
const LOCALE_INFO: &str = include_str!("../../locale-info.json");
|
||||
|
||||
/// This tool can be used to prepare a Proxmox installation ISO for automated installations.
|
||||
/// Additional uses are to validate the format of an answer file or to test match filters and
|
||||
/// print information on the properties to match against for the current hardware.
|
||||
@ -589,8 +593,11 @@ fn parse_answer(path: impl AsRef<Path> + fmt::Debug) -> Result<Answer> {
|
||||
if let Err(err) = file.read_to_string(&mut contents) {
|
||||
bail!("Reading from file {path:?} failed: {err}");
|
||||
}
|
||||
|
||||
match toml::from_str(&contents) {
|
||||
Ok(answer) => {
|
||||
verify_locale_settings(&answer, &serde_json::from_str(LOCALE_INFO)?)?;
|
||||
verify_first_boot_settings(&answer)?;
|
||||
verify_email_and_root_password_settings(&answer)?;
|
||||
println!("The answer file was parsed successfully, no errors found!");
|
||||
Ok(answer)
|
||||
|
@ -291,7 +291,7 @@ fn verify_filesystem_settings(answer: &Answer, setup_info: &SetupInfo) -> Result
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_locale_settings(answer: &Answer, locales: &LocaleInfo) -> Result<()> {
|
||||
pub fn verify_locale_settings(answer: &Answer, locales: &LocaleInfo) -> Result<()> {
|
||||
info!("Verifying locale settings");
|
||||
if !locales
|
||||
.countries
|
||||
@ -335,7 +335,7 @@ pub fn verify_email_and_root_password_settings(answer: &Answer) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn verify_first_boot_settings(answer: &Answer) -> Result<()> {
|
||||
pub fn verify_first_boot_settings(answer: &Answer) -> Result<()> {
|
||||
info!("Verifying first boot settings");
|
||||
|
||||
if let Some(first_boot) = &answer.first_boot {
|
||||
|
Loading…
Reference in New Issue
Block a user