diff --git a/proxmox-auto-install-assistant/src/main.rs b/proxmox-auto-install-assistant/src/main.rs index 6796c06..969922c 100644 --- a/proxmox-auto-install-assistant/src/main.rs +++ b/proxmox-auto-install-assistant/src/main.rs @@ -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 + fmt::Debug) -> Result { 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) diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs index c26b33c..fbf874e 100644 --- a/proxmox-auto-installer/src/utils.rs +++ b/proxmox-auto-installer/src/utils.rs @@ -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 {