refactor
This commit is contained in:
parent
eabd898ccf
commit
f2b1a43f62
13 changed files with 453 additions and 390 deletions
27
src/install/user.rs
Normal file
27
src/install/user.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use crate::{config::UserConfig, run_command};
|
||||
|
||||
use super::str_vec;
|
||||
|
||||
pub fn setup_users(conf: &[UserConfig]) {
|
||||
let mut doas_conf = String::new();
|
||||
|
||||
for user in conf {
|
||||
run_command(
|
||||
&str_vec(vec!["arch-chroot", "/mnt", "useradd", "-m", &user.name]),
|
||||
None,
|
||||
false,
|
||||
);
|
||||
|
||||
run_command(
|
||||
&str_vec(vec!["arch-chroot", "/mnt", "passwd", &user.name]),
|
||||
Some(&format!("{}\n{}\n", user.password, user.password)),
|
||||
false,
|
||||
);
|
||||
|
||||
if user.doas_root {
|
||||
doas_conf.push_str(&format!("permit {} as root\n", user.name));
|
||||
}
|
||||
}
|
||||
|
||||
std::fs::write("/mnt/etc/doas.conf", doas_conf).unwrap();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue