: ${net_alias_conf:=/var/run/netaliases.conf} net_alias_init() { [ ! -f $net_alias_conf ] && \ echo "net_aliases_loaded=yes" > $net_alias_conf } # # net_alias_add name device [ prefix ] # net_alias_add() { local name="$1" local dev="$2" local pf="$3" local rname=`echo "$name" | tr ' .+-' '____'` local rdev=`echo "$dev" | tr ' .+-' '____'` eval "net_${pf}dev_$rname=\"$dev\"" eval "net_${pf}name_$rdev=\"$name\"" { echo "net_${pf}dev_$rname='$dev'" echo "net_${pf}name_$rdev='$name'" } >>$net_alias_conf } net_alias_del() { local rname=`echo "$1" | tr ' .+-' '____'` sed -i -e "/^net_dev_$rname=/d;/^net_name_.*='$1'/d" $net_alias_conf } net_alias_lookup() { if [ ! "$net_aliases_loaded" ]; then . $net_alias_conf fi local postfix=`echo "$2" | tr ' .+-' '____'` eval local tmp=\"\$net_$4$1_$postfix\" if [ "$tmp" ]; then eval $3="\"$tmp\"" return 0 fi return 1 } net_alias_lookup_dev() { net_alias_lookup dev "$1" $2 $3 } net_alias_lookup_name() { net_alias_lookup name "$1" $2 $3 }