diff --git a/src/config/file.rs b/src/config/file.rs new file mode 100644 index 0000000000000000000000000000000000000000..0b34aeb2189e0d841c801021cf9fd2a55ff7e790 --- /dev/null +++ b/src/config/file.rs @@ -0,0 +1,5 @@ +#[derive(Debug, Default, Deserialize)] +pub struct FileConfig { + pub path: String, + pub data: String +} diff --git a/src/config/mod.rs b/src/config/mod.rs index d9cee066e5b5e66d177514ba72759eab3bb42d03..8418384aedb384b3da605bd30215103c1145fe06 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,12 +1,14 @@ use std::collections::BTreeMap; mod general; +mod file; mod package; mod user; #[derive(Debug, Default, Deserialize)] pub struct Config { pub general: general::GeneralConfig, + pub files: Vec<file::FileConfig>, pub packages: BTreeMap<String, package::PackageConfig>, pub users: BTreeMap<String, user::UserConfig>, } diff --git a/src/install/mod.rs b/src/install/mod.rs index 5dd65ea0d20f6511772a18e25a96a1be3337b460..d0af357c5ac0d9edf4e58d53478d745983415a7e 100644 --- a/src/install/mod.rs +++ b/src/install/mod.rs @@ -74,7 +74,7 @@ pub fn install(config: Config) -> Result<(), String> { Err(err) => Err(err) } } else { - Ok($def) + Ok($dst.unwrap_or($def)) }) } @@ -105,11 +105,15 @@ pub fn install(config: Config) -> Result<(), String> { } dir!(""); + dir!("bin"); dir!("etc"); dir!("home"); - let mut passwd = String::new(); + for file in config.files { + file!(file.path.trim_matches('/'), file.data.as_bytes()); + } + let mut passwd = String::new(); let mut next_uid = 1000; for (username, user) in config.users { let password = if let Some(password) = user.password { @@ -144,7 +148,6 @@ pub fn install(config: Config) -> Result<(), String> { passwd.push_str(&format!("{};{};{};{};{};{};{}\n", username, password, uid, gid, name, home, shell)); } - file!("etc/passwd", passwd.as_bytes()); Ok(())