move pstab to td-ps, improve td-gnuplot
[hband-tools.git] / root-tools / syncifstate
blobcfe87cc6f19cdf99934db50c5a795214e95e8101
1 #!/bin/bash
3 f="/etc/network/run/ifstate"
5 export IFS="$IFS="
6 cat "$f" | \
8 declare -A ifaces
10 while read alias phy
12 ifaces[$alias]=1
13 if [ -z "$1" -o "$alias" = "$1" ]
14 then
15 if ! ip link show "$phy" | grep -q -w UP
16 then
17 sed -i "$f" -e "/^$alias=$phy\$/d"
20 done
21 ip -o link show | \
22 while read n iface rest
24 iface=${iface%:*}
25 if [ -z "${ifaces[$iface]}" ]
26 then
27 if grep -q -w UP <<<"$rest"
28 then
29 echo "$iface=$iface" >>"$f"
32 done