Полностью доведена production-логика AWG2 harness по up2: strict execution, tc parser, anti-torrent, status и документация

This commit is contained in:
2026-05-09 23:38:53 +05:00
parent e7818054e8
commit d9f140b3e0
18 changed files with 699 additions and 146 deletions
+12 -4
View File
@@ -19,7 +19,10 @@ pub fn ensure_swap(cfg: &Config) -> anyhow::Result<()> {
);
}
} else {
run("fallocate", &["-l", &format!("{}M", cfg.swap.size_mb), path])?;
run(
"fallocate",
&["-l", &format!("{}M", cfg.swap.size_mb), path],
)?;
run("chmod", &["600", path])?;
run("mkswap", &[path])?;
}
@@ -31,7 +34,10 @@ pub fn ensure_swap(cfg: &Config) -> anyhow::Result<()> {
}
ensure_fstab(path, cfg.swap.priority)?;
run("sysctl", &["-w", &format!("vm.swappiness={}", cfg.swap.swappiness)])?;
run(
"sysctl",
&["-w", &format!("vm.swappiness={}", cfg.swap.swappiness)],
)?;
ensure_swappiness_persist(cfg.swap.swappiness)?;
Ok(())
}
@@ -39,7 +45,10 @@ pub fn ensure_swap(cfg: &Config) -> anyhow::Result<()> {
fn ensure_fstab(path: &str, priority: i32) -> anyhow::Result<()> {
let file = "/etc/fstab";
let content = fs::read_to_string(file).unwrap_or_default();
if content.lines().any(|l| l.contains(path) && l.contains("swap")) {
if content
.lines()
.any(|l| l.contains(path) && l.contains("swap"))
{
return Ok(());
}
let line = format!("{path} none swap sw,pri={priority} 0 0\n");
@@ -69,4 +78,3 @@ fn ensure_swappiness_persist(swappiness: u8) -> anyhow::Result<()> {
}
Ok(())
}