22 |
return 0 |
return 0 |
23 |
} |
} |
24 |
|
|
25 |
|
iface_has_link() |
26 |
|
{ |
27 |
|
local interface="$1" |
28 |
|
local flags |
29 |
|
|
30 |
|
[[ -n ${interface} ]] || return 2 |
31 |
|
interface="/sys/class/net/${interface}" |
32 |
|
[[ -d ${interface} ]] || return 2 |
33 |
|
flags=$(cat ${interface}/flags) |
34 |
|
echo $((${flags}|0x41)) > ${interface}/flags # 0x41: IFF_UP|IFF_RUNNING |
35 |
|
[ "$(cat ${interface}/carrier)" = 1 ] || return 1 |
36 |
|
} |
37 |
|
|
38 |
# read values from files |
# read values from files |
39 |
read_value() |
read_value() |
40 |
{ |
{ |
482 |
# setup static or dhcp |
# setup static or dhcp |
483 |
case ${NETWORKING} in |
case ${NETWORKING} in |
484 |
dhcp|DHCP) |
dhcp|DHCP) |
485 |
${DHCP_PROG} ${DHCP_START} "${iface}" ;; |
if iface_has_link "${iface}" |
486 |
|
then |
487 |
|
${DHCP_PROG} ${DHCP_START} "${iface}" |
488 |
|
else |
489 |
|
echo "Interface '${iface}' has no link. Not running '${DHCP_PROG}'." |
490 |
|
fi |
491 |
|
;; |
492 |
static|STATIC) |
static|STATIC) |
493 |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" ;; |
ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" ;; |
494 |
esac |
esac |