version 1.230, 2022/12/05 20:12:00 |
version 1.231, 2022/12/16 04:04:25 |
|
|
# Start a single interface. |
# Start a single interface. |
# Usage: ifstart if1 |
# Usage: ifstart if1 |
ifstart() { |
ifstart() { |
local _if=$1 _hn=/etc/hostname.$1 _cmds _i=0 _line _stat |
local _if=$1 _lladdr _hn=/etc/hostname.$1 _cmds _i=0 _line _stat |
set -A _cmds |
set -A _cmds |
|
|
if [[ $_if == ??:??:??:??:??:?? ]]; then |
# Interface names must be alphanumeric only. We check to avoid |
if ! _line=$( ifconfig -M $_if ); then |
# configuring backup or temp files, and to catch the "*" case. |
print -u2 "${0##*/}: $_if is not unique." |
if [[ $_if == +([[:alpha:]])+([[:digit:]]) ]]; then |
|
_lladdr=$(ifconfig $_if 2>/dev/null | |
|
sed -n 's/^[[:space:]]*lladdr[[:space:]]//p') |
|
if [[ -n $_lladdr && -f /etc/hostname.$_lladdr && \ |
|
-n $(ifconfig -M "$_lladdr") ]]; then |
|
print -u2 "${0##*/}: $_hn: /etc/hostname.$_lladdr overrides" |
return |
return |
fi |
fi |
|
|
[[ -z $_line ]] && return |
# We also support hostname.lladdr, but it must resolve to be valid |
_if=$_line |
elif [[ $_if == ??:??:??:??:??:?? ]]; then |
_line= |
_lladdr=$_if |
|
_if=$(ifconfig -M $_lladdr) |
if [[ -e /etc/hostname.$_if ]]; then |
if (($? != 0)); then |
print -u2 "${0##*/}: $_hn: /etc/hostname.$_if overrides" |
print -u2 "${0##*/}: $_lladdr is not unique." |
return |
return |
fi |
fi |
fi |
|
|
|
# Interface names must be alphanumeric only. We check to avoid |
[[ -z $_if ]] && return |
# configuring backup or temp files, and to catch the "*" case. |
else |
[[ $_if != +([[:alpha:]])+([[:digit:]]) ]] && return |
return |
|
fi |
|
|
if [[ ! -f $_hn ]]; then |
if [[ ! -f $_hn ]]; then |
print -u2 "${0##*/}: $_hn: No such file or directory." |
print -u2 "${0##*/}: $_hn: No such file or directory." |