✨ 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')
|
arch=('x86_64' 'aarch64')
|
||||||
url="https://git.hydrar.de/navos/navinstall"
|
url="https://git.hydrar.de/navos/navinstall"
|
||||||
license=("MIT")
|
license=("MIT")
|
||||||
depends=("arch-install-scripts" "git")
|
depends=("arch-install-scripts" "git" "wpa_supplicant")
|
||||||
optdepends=('sbctl' 'sbsigntools' 'archiso')
|
optdepends=('sbctl' 'sbsigntools' 'archiso')
|
||||||
makedepends=("rustup" "git")
|
makedepends=("rustup" "git")
|
||||||
source=("${pkgname}::git+https://git.hydrar.de/navos/navinstall.git")
|
source=("${pkgname}::git+https://git.hydrar.de/navos/navinstall.git")
|
||||||
|
|
|
@ -125,3 +125,8 @@ gpu = true
|
||||||
models = [
|
models = [
|
||||||
"llama3.1:8b"
|
"llama3.1:8b"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Setup predefined WLAN
|
||||||
|
[wlan]
|
||||||
|
ssid = "SSID"
|
||||||
|
passphrase = "pass"
|
||||||
|
|
|
@ -19,6 +19,14 @@ pub struct InstallConfig {
|
||||||
pub ssh: Option<SSHConfig>,
|
pub ssh: Option<SSHConfig>,
|
||||||
/// Ollama AI Config
|
/// Ollama AI Config
|
||||||
pub ai: Option<OllamaConfig>,
|
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)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
|
|
@ -50,7 +50,8 @@ pub mod zram;
|
||||||
// TODO : Make zsh default + completions
|
// TODO : Make zsh default + completions
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::InstallConfig,
|
config::{InstallConfig, WlanConfig},
|
||||||
|
linux::run_command,
|
||||||
pkg::{self, install_pkgs, pacstrap_at, setup_kernel},
|
pkg::{self, install_pkgs, pacstrap_at, setup_kernel},
|
||||||
print_status,
|
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();
|
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) {
|
pub fn install_mnt(conf: InstallConfig, bare: bool) {
|
||||||
// Base Install
|
// Base Install
|
||||||
pacstrap_at("/mnt", &conf.pkg.pkg);
|
pacstrap_at("/mnt", &conf.pkg.pkg);
|
||||||
|
@ -151,6 +179,11 @@ pub fn install_mnt(conf: InstallConfig, bare: bool) {
|
||||||
// Configuration
|
// Configuration
|
||||||
first_boot_values(&conf.general);
|
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) {
|
if !matches!(conf.general.mode, crate::config::InstallMode::Base) {
|
||||||
setup_navos("/mnt");
|
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