root pw + min
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
JMARyA 2025-01-05 04:48:28 +01:00
parent a3da9fb9ac
commit 40a1498c6f
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
7 changed files with 72 additions and 15 deletions

View file

@ -30,6 +30,9 @@ timezone = "Europe/Berlin"
# Hostname # Hostname
hostname = "navos" hostname = "navos"
# Root password
root_password = "root"
[pkg] [pkg]
# Additional packages # Additional packages
pkg = [ pkg = [

38
installs/min.toml Normal file
View file

@ -0,0 +1,38 @@
# Minimal Install Template
# Drive Selection for Install
[drive]
# Device node for the EFI boot filesystem
boot = "/dev/null"
# Device node for the root filesystem
root = "/dev/null"
# Root filesystem encryption passphrase
# If this option is set the root filesystem will be encrypted with LUKS
encryption = "password"
# General configuration
[general]
# Preset
mode = "Base"
# System Locale
locale = "de_DE.UTF-8"
# Keymap
keyboard_layout = "de"
keyboard_variant = "mac"
# Timezone
timezone = "Europe/Berlin"
# Hostname
hostname = "navos_min"
# Root password
root_password = "root"
[pkg]
# Additional packages
pkg = []

View file

@ -12,7 +12,7 @@ pub struct InstallConfig {
/// Package Configuration /// Package Configuration
pub pkg: PackageConfig, pub pkg: PackageConfig,
/// User Configuration /// User Configuration
pub user: Vec<UserConfig>, pub user: Option<Vec<UserConfig>>,
/// SSH Configuration /// SSH Configuration
pub ssh: Option<SSHConfig>, pub ssh: Option<SSHConfig>,
/// Ollama AI Config /// Ollama AI Config
@ -49,9 +49,9 @@ pub struct PackageConfig {
/// Packages to install /// Packages to install
pub pkg: Vec<String>, pub pkg: Vec<String>,
/// Enable libvirt /// Enable libvirt
pub virtualization: bool, pub virtualization: Option<bool>,
/// Enable docker /// Enable docker
pub docker: bool, pub docker: Option<bool>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
@ -78,6 +78,8 @@ pub struct GeneralConfig {
pub timezone: String, pub timezone: String,
/// Hostname /// Hostname
pub hostname: String, pub hostname: String,
// Root password
pub root_password: Option<String>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View file

@ -6,7 +6,7 @@ use crate::{
print_status, print_status,
}; };
use super::uncomment_first_value_of; use super::{uncomment_first_value_of, user::change_passwd};
/// Generate the `/etc/fstab` file /// Generate the `/etc/fstab` file
pub fn genfstab() { pub fn genfstab() {
@ -51,6 +51,10 @@ pub fn first_boot_values(conf: &GeneralConfig) {
arch_chroot(&["hwclock", "--systohc"], None, false); arch_chroot(&["hwclock", "--systohc"], None, false);
if let Some(root_pw) = &conf.root_password {
change_passwd("root", root_pw);
}
systemd_service_enable("NetworkManager.service"); systemd_service_enable("NetworkManager.service");
} }

View file

@ -88,7 +88,7 @@ pub fn install(conf: InstallConfig) {
// System Setup // System Setup
first_boot_values(&conf.general); first_boot_values(&conf.general);
setup_skel(&conf.general); setup_skel(&conf.general);
setup_users(&conf.user); setup_users(&conf.user.unwrap_or_default());
setup_ssh(conf.ssh); setup_ssh(conf.ssh);
@ -118,11 +118,11 @@ pub fn install(conf: InstallConfig) {
} }
} }
if conf.pkg.virtualization { if conf.pkg.virtualization.unwrap_or_default() {
// TODO : Enable virtualization // TODO : Enable virtualization
} }
if conf.pkg.docker { if conf.pkg.docker.unwrap_or_default() {
// TODO : Enable docker // TODO : Enable docker
} }

View file

@ -4,6 +4,10 @@ use crate::{
print_status, print_status,
}; };
pub fn change_passwd(user: &str, pw: &str) {
arch_chroot(&["passwd", user], Some(&format!("{}\n{}\n", pw, pw)), false);
}
/// Setup the users of the system /// Setup the users of the system
pub fn setup_users(conf: &[UserConfig]) { pub fn setup_users(conf: &[UserConfig]) {
let mut doas_conf = String::new(); let mut doas_conf = String::new();
@ -11,11 +15,7 @@ pub fn setup_users(conf: &[UserConfig]) {
for user in conf { for user in conf {
arch_chroot(&["useradd", "-m", &user.name], None, false); arch_chroot(&["useradd", "-m", &user.name], None, false);
arch_chroot( change_passwd(&user.name, &user.password);
&["passwd", &user.name],
Some(&format!("{}\n{}\n", user.password, user.password)),
false,
);
if user.doas_root { if user.doas_root {
print_status(&format!("Allowing root doas for {}", user.name)); print_status(&format!("Allowing root doas for {}", user.name));

View file

@ -57,16 +57,23 @@ pub fn print_config(conf: &InstallConfig) {
"Timezone:".paint(Color::Yellow), "Timezone:".paint(Color::Yellow),
conf.general.timezone conf.general.timezone
)); ));
if conf.general.root_password.is_some() {
general_info.add_str(format!(
"🔑 {} {}",
"Root Password".paint(Color::Yellow),
"✔️".paint(Color::Green)
));
}
root_info.add_tree("🔨 General", general_info); root_info.add_tree("🔨 General", general_info);
let mut pkg_info = Tree::new(); let mut pkg_info = Tree::new();
if conf.pkg.docker { if conf.pkg.docker.unwrap_or_default() {
pkg_info.add_str(format!("🐳 Docker {}", "✔️".paint(Color::Green))); pkg_info.add_str(format!("🐳 Docker {}", "✔️".paint(Color::Green)));
} }
if conf.pkg.virtualization { if conf.pkg.virtualization.unwrap_or_default() {
pkg_info.add_str(format!("🎃 Virtualization {}", "✔️".paint(Color::Green))); pkg_info.add_str(format!("🎃 Virtualization {}", "✔️".paint(Color::Green)));
} }
@ -81,7 +88,10 @@ pub fn print_config(conf: &InstallConfig) {
let mut users_info = Tree::new(); let mut users_info = Tree::new();
for user in &conf.user { let empty = Vec::new();
let user_conf = conf.user.as_ref().unwrap_or(&empty);
for user in user_conf {
users_info.add_str(format!( users_info.add_str(format!(
"👤 {} {}", "👤 {} {}",
user.name, user.name,