version 1.218, 2022/06/26 09:36:13 |
version 1.219, 2022/07/03 12:14:36 |
|
|
exit 1 |
exit 1 |
} |
} |
|
|
|
# Test the first argument against the remaining ones, return success on a match. |
|
isin() { |
|
local _a=$1 _b |
|
|
|
shift |
|
for _b; do |
|
[[ $_a == "$_b" ]] && return 0 |
|
done |
|
return 1 |
|
} |
|
|
# Echo file $1 to stdout. Skip comment lines. Strip leading and trailing |
# Echo file $1 to stdout. Skip comment lines. Strip leading and trailing |
# whitespace if IFS is set. |
# whitespace if IFS is set. |
# Usage: stripcom /path/to/file |
# Usage: stripcom /path/to/file |
|
|
} |
} |
|
|
# Create interfaces for network pseudo-devices referred to by hostname.if files. |
# Create interfaces for network pseudo-devices referred to by hostname.if files. |
# Usage: vifscreate |
# Optionally, limit creation to given interfaces only. |
|
# Usage: vifscreate [if ...] |
vifscreate() { |
vifscreate() { |
local _vif _hn _if |
local _vif _hn _if |
|
|
|
|
# loopback for routing domain is created by kernel |
# loopback for routing domain is created by kernel |
[[ -n ${_if##lo[1-9]*} ]] || continue |
[[ -n ${_if##lo[1-9]*} ]] || continue |
|
|
|
if (($# > 0)) && ! isin $_if "$@"; then |
|
continue |
|
fi |
|
|
if ! ifcreate $_if; then |
if ! ifcreate $_if; then |
print -u2 "${0##*/}: create for '$_if' failed." |
print -u2 "${0##*/}: create for '$_if' failed." |
fi |
fi |
|
|
|
|
# If we were invoked with a list of interface names, just reconfigure these |
# If we were invoked with a list of interface names, just reconfigure these |
# interfaces (or bridges), add default routes and return. |
# interfaces (or bridges), add default routes and return. |
|
# Create virtual interfaces upfront to make ifconfig commands depending on |
|
# other interfaces, e.g. "patch", work regardless of in which order interface |
|
# names were specified. |
if (($# > 0)); then |
if (($# > 0)); then |
|
vifscreate "$@" |
for _if; do ifstart $_if; done |
for _if; do ifstart $_if; done |
defaultroute |
defaultroute |
return |
return |