✨ auto wlan
This commit is contained in:
parent
b2c21e62c4
commit
047f8eccce
5 changed files with 66 additions and 2 deletions
2
PKGBUILD
2
PKGBUILD
|
@ -6,7 +6,7 @@ pkgdesc="navOS Installer"
|
|||
arch=('x86_64' 'aarch64')
|
||||
url="https://git.hydrar.de/navos/navinstall"
|
||||
license=("MIT")
|
||||
depends=("arch-install-scripts" "git")
|
||||
depends=("arch-install-scripts" "git" "wpa_supplicant")
|
||||
optdepends=('sbctl' 'sbsigntools' 'archiso')
|
||||
makedepends=("rustup" "git")
|
||||
source=("${pkgname}::git+https://git.hydrar.de/navos/navinstall.git")
|
||||
|
|
|
@ -125,3 +125,8 @@ gpu = true
|
|||
models = [
|
||||
"llama3.1:8b"
|
||||
]
|
||||
|
||||
# Setup predefined WLAN
|
||||
[wlan]
|
||||
ssid = "SSID"
|
||||
passphrase = "pass"
|
||||
|
|
|
@ -19,6 +19,14 @@ pub struct InstallConfig {
|
|||
pub ssh: Option<SSHConfig>,
|
||||
/// Ollama AI Config
|
||||
pub ai: Option<OllamaConfig>,
|
||||
// WLAN
|
||||
pub wlan: Option<WlanConfig>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct WlanConfig {
|
||||
pub ssid: String,
|
||||
pub passphrase: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
|
|
|
@ -50,7 +50,8 @@ pub mod zram;
|
|||
// TODO : Make zsh default + completions
|
||||
|
||||
use crate::{
|
||||
config::InstallConfig,
|
||||
config::{InstallConfig, WlanConfig},
|
||||
linux::run_command,
|
||||
pkg::{self, install_pkgs, pacstrap_at, setup_kernel},
|
||||
print_status,
|
||||
};
|
||||
|
@ -134,6 +135,33 @@ pub fn setup_pacman(dir: &str, conf: &str) {
|
|||
std::fs::write(dir.join("etc").join("pacman.conf"), content).unwrap();
|
||||
}
|
||||
|
||||
pub fn setup_wlan(wlan: &WlanConfig) {
|
||||
print_status("Setting base wlan");
|
||||
install_pkgs(&["networkmanager"]);
|
||||
let res = run_command(
|
||||
&[
|
||||
"wpa_passphrase",
|
||||
wlan.ssid.as_str(),
|
||||
wlan.passphrase.as_str(),
|
||||
],
|
||||
None,
|
||||
false,
|
||||
)
|
||||
.0;
|
||||
let psk = res
|
||||
.lines()
|
||||
.find(|x| x.trim().starts_with("psk"))
|
||||
.map(|x| x.trim_start_matches("psk=").to_string())
|
||||
.unwrap();
|
||||
std::fs::write(
|
||||
"/mnt/etc/NetworkManager/system-connections/base.nmconnection",
|
||||
include_str!("../root/wlan.nmconnection")
|
||||
.replace("<PSK>", &psk)
|
||||
.replace("<SSID>", &wlan.ssid),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn install_mnt(conf: InstallConfig, bare: bool) {
|
||||
// Base Install
|
||||
pacstrap_at("/mnt", &conf.pkg.pkg);
|
||||
|
@ -151,6 +179,11 @@ pub fn install_mnt(conf: InstallConfig, bare: bool) {
|
|||
// Configuration
|
||||
first_boot_values(&conf.general);
|
||||
|
||||
// Setup network
|
||||
if let Some(wlan) = &conf.wlan {
|
||||
setup_wlan(wlan);
|
||||
}
|
||||
|
||||
if !matches!(conf.general.mode, crate::config::InstallMode::Base) {
|
||||
setup_navos("/mnt");
|
||||
}
|
||||
|
|
18
src/root/wlan.nmconnection
Normal file
18
src/root/wlan.nmconnection
Normal file
|
@ -0,0 +1,18 @@
|
|||
[connection]
|
||||
id=BaseWiFi
|
||||
type=wifi
|
||||
autoconnect=true
|
||||
|
||||
[wifi]
|
||||
ssid=<SSID>
|
||||
mode=infrastructure
|
||||
|
||||
[wifi-security]
|
||||
key-mgmt=wpa-psk
|
||||
psk=<PSK>
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
method=auto
|
Loading…
Add table
Add a link
Reference in a new issue