refactor
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
JMARyA 2025-01-04 21:37:49 +01:00
parent bc69d74ac2
commit 30e2db26ca
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
18 changed files with 257 additions and 337 deletions

View file

@ -1,19 +1,18 @@
use crate::{config::UserConfig, print_status, run_command};
use super::str_vec;
use crate::{
config::UserConfig,
linux::{arch_chroot, install_file},
print_status,
};
/// Setup the users of the system
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,
);
arch_chroot(&["useradd", "-m", &user.name], None, false);
run_command(
&str_vec(vec!["arch-chroot", "/mnt", "passwd", &user.name]),
arch_chroot(
&["passwd", &user.name],
Some(&format!("{}\n{}\n", user.password, user.password)),
false,
);
@ -24,5 +23,5 @@ pub fn setup_users(conf: &[UserConfig]) {
}
}
std::fs::write("/mnt/etc/doas.conf", doas_conf).unwrap();
install_file("/mnt/etc/doas.conf", &doas_conf, 0o644);
}