confz

git mirror of https://ccx.te2000.cz/bzr/confz
git clone https://ccx.te2000.cz/git/confz
Log | Files | Refs

commit b2d03e3914f44560470af860ec214d4276814e18
parent 7f328bc95e6a23928d90641b07d01b9be1175e44
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Sun, 29 Jun 2014 04:15:38 +0200

ip module
Diffstat:
Azsh-functions/confz_ip_init | 34++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+), 0 deletions(-)

diff --git a/zsh-functions/confz_ip_init b/zsh-functions/confz_ip_init @@ -0,0 +1,34 @@ +# vim: ft=zsh noet ts=4 sts=4 sw=4 + +# +# confz functions for dealing with iproute2 +# + + +confz_rename_interface_check() { + checkvars name mac + + # local -A ifaces + local ignored iface mac rest out ok old_name + + out=$( confz_do ip link show ) || die "ip failed" + + ok=0 + while read ignored iface rest; do + read ignored mac rest + if [[ ${iface%:} == $vars[name] ]]; then + [[ $mac == $vars[mac] ]] || \ + "${(qqq)iface%:} already exists with different MAC address" + ok=1 + break + fi + if ! (($+old_name)) && [[ $mac == $vars[mac] ]]; then + old_name=${iface%:} + fi + done <<<$out + + (($+old_name)) || die "could not find interface with MAC: $vars[mac]" + + do_command=( ip link set dev $old_name name $vars[name] ) + (($ok)) +}