From 6fb7762d9d058cea59b56b1ace91b4ccffc3b2fbac289e88bd5f9de1c4d12329 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 22 Dec 2025 11:40:07 +0300 Subject: [PATCH] netreconf is replaced by apply-s --- netreconf | 70 ------------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100755 netreconf diff --git a/netreconf b/netreconf deleted file mode 100755 index 2f495d6..0000000 --- a/netreconf +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env jimsh -# Generate network reconfiguration commands, based on dsc's net/ -# configuration and current interfaces state. -# Copyright (C) 2025 Sergey Matveev -# -# That script calls dsc command, so do not forget proper $DSC_STASH value. -# It outputs ip-* commands to stdout, intending you to feed to the shell. - -proc list-addrs {iface} { - set addrs [list] - catch {exec ip addr list dev $iface} lines - foreach l [split $lines \n] { - if {[regexp {inet (\S+)} $l _ addr]} { - lappend addrs $addr - } - if {[regexp {inet6 (\S+)} $l _ addr] && [string range $addr 0 4] != "fe80:"} { - lappend addrs $addr - } - } - return $addrs -} - -# Get list of non-loopback system interfaces -set sysIfaces [list] -foreach l [split [exec ip link] \n] { - if {[regexp {^\d+: (\w+): } $l _ iface] && $iface != "lo"} { - lappend sysIfaces $iface - } -} - -set dscIfaces [split [exec dsc get net/*] \n] - -foreach iface $sysIfaces { - if {[lsearch -exact $dscIfaces $iface] == -1} { - # If interface is not mentioned in dsc, then disable it and remove - # all addresses, as they are still known to the system - puts "ip link set $iface down" - foreach addr [list-addrs $iface] { - puts "ip addr del $addr dev $iface" - } - } else { - set mtu [exec dsc get net/$iface/mtu] - puts "ip link set $iface mtu $mtu" - puts "ip link set $iface up" - } -} - -foreach iface $dscIfaces { - if {[lsearch -exact $sysIfaces $iface] == -1} { - # If dsc's interface is not present in the system, skip it - continue - } - set dscAddrs [list] - foreach addr [split [exec dsc get net/$iface/addr/*] \n] { - set prefixlen [exec dsc get net/$iface/addr/$addr/prefixlen] - lappend dscAddrs $addr/$prefixlen - } - foreach addr [list-addrs $iface] { - set idx [lsearch -exact $dscAddrs $addr] - if {$idx == -1} { - puts "ip addr del $addr dev $iface" - } else { - # Address is already present - set $dscAddrs [lreplace $dscAddrs $idx $idx] - } - } - foreach addr $dscAddrs { - puts "ip addr add $addr dev $iface" - } -} -- 2.52.0