dpkg setup adds an auto-generated node-id

This commit is contained in:
Herbert Wolverson 2023-03-17 14:24:24 +00:00
parent 8146472479
commit adc3bb8eeb
3 changed files with 8 additions and 2 deletions

1
src/rust/Cargo.lock generated
View File

@ -1413,6 +1413,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"colored", "colored",
"default-net", "default-net",
"uuid",
] ]
[[package]] [[package]]

View File

@ -5,4 +5,5 @@ edition = "2021"
[dependencies] [dependencies]
colored = "2" colored = "2"
default-net = "0" # For obtaining an easy-to-use NIC list default-net = "0" # For obtaining an easy-to-use NIC list
uuid = { version = "1", features = ["v4", "fast-rng" ] }

View File

@ -1,5 +1,6 @@
use colored::Colorize; use colored::Colorize;
use default_net::{get_interfaces, interface::InterfaceType, Interface}; use default_net::{get_interfaces, interface::InterfaceType, Interface};
use uuid::Uuid;
use std::{fs, path::Path, process::Command}; use std::{fs, path::Path, process::Command};
fn get_available_interfaces() -> Vec<Interface> { fn get_available_interfaces() -> Vec<Interface> {
@ -117,6 +118,7 @@ fn get_bandwidth(up: bool) -> u32 {
const ETC_LQOS_CONF: &str = "lqos_directory = '/opt/libreqos/src' const ETC_LQOS_CONF: &str = "lqos_directory = '/opt/libreqos/src'
queue_check_period_ms = 1000 queue_check_period_ms = 1000
node_id = {NODE_ID}
[tuning] [tuning]
stop_irq_balance = true stop_irq_balance = true
@ -138,8 +140,10 @@ vlan_mapping = []
"; ";
fn write_etc_lqos_conf(internet: &str, isp: &str) { fn write_etc_lqos_conf(internet: &str, isp: &str) {
let new_id = Uuid::new_v4().to_string();
let output = let output =
ETC_LQOS_CONF.replace("{INTERNET}", internet).replace("{ISP}", isp); ETC_LQOS_CONF.replace("{INTERNET}", internet).replace("{ISP}", isp)
.replace("{NODE_ID}", &new_id);
fs::write(LQOS_CONF, output).expect("Unable to write file"); fs::write(LQOS_CONF, output).expect("Unable to write file");
} }