#!/bin/zsh

interf=$1

. /sbin/menus/primitives

set -A noms "Adresse IP ${interf}" "Masque ${interf}" "Gateway"
set -A fonctions "show_address" "show_mask" "show_address"
set -A param "CFG_IF_${interf}_ADDR" "CFG_IF_${interf}_MASK" "CFG_IF_${interf}_GW"

eval CFG_IF_${interf}_ADDR=`grep "^${interf}_ip_address=" /etc/config.rc |cut -f2 -d=|cut -f1 -d/`
eval CFG_IF_${interf}_MASK=`grep "^${interf}_ip_address=" /etc/config.rc |cut -f2 -d=|cut -f2 -d/`
eval CFG_IF_${interf}_GW=`grep "^ip_route=default:" /etc/config.rc |cut -f2 -d:`

if [ -e /tmp/unsaved-addr-${interf} ]; then
	. /tmp/unsaved-addr-${interf}
fi

display_items "adressage"

echo "# ${interf} setup" > /tmp/unsaved-addr-${interf}
for i in CFG_IF_${interf}_ADDR CFG_IF_${interf}_MASK CFG_IF_${interf}_GW; do
	eval echo $i=$"$i" >> /tmp/unsaved-addr-${interf}
done

