# 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 old_name out=$( confz_do ip link show ) || die "ip failed" while read ignored iface rest; do read ignored mac rest if [[ ${iface%:} == $vars[name] ]]; then [[ $mac == $vars[mac] ]] || \ die "${(qqq)iface%:} already exists with different MAC address" return 0 fi if [[ -z $old_name && $mac == $vars[mac] ]]; then old_name=${iface%:} fi done <<<$out [[ -n $old_name ]] || die "could not find interface with MAC: $vars[mac]" do_command=( ip link set dev $old_name name $vars[name] ) return 1 }