diff options
Diffstat (limited to 'network')
-rwxr-xr-x | network | 34 |
1 files changed, 11 insertions, 23 deletions
@@ -23,24 +23,9 @@ deprecated() { printf " connection, or use a utility such as netcfg.\n" } -have_interface() { - if [[ -z $1 ]]; then - printf "\n${C_FAIL}Error:${C_CLEAR} \`interface' is undefined in /etc/rc.conf\n" - return 1 - fi - - if [[ ! -d /sys/class/net/$1 ]]; then - printf "\n${C_FAIL}Error:${C_CLEAR} unknown interface in /etc/rc.conf: \`%s'\n" "$1" - return 1 - fi -} - network_up() { - have_interface "$interface" || return 1 - - ip link set dev $interface up || return 1 - if [[ $address ]]; then + ip link set dev $interface up || return 1 ip addr add $address/${netmask:-24} broadcast ${broadcast:-+} dev $interface || return 1 [[ $gateway ]] && { ip route add default via $gateway || return 1; } else @@ -49,15 +34,18 @@ network_up() { } network_down() { - have_interface "$interface" || return 1 - - if [[ -f /run/dhcpcd-$interface.pid ]]; then - dhcpcd -qk $interface || return 1 + if [[ ! -n $interface ]]; then + if [[ -f /run/dhcpcd.pid ]]; then + dhcpcd -qk || return 1 + fi else - ip addr flush dev $interface || return 1 + if [[ ! -n $address && -f /run/dhcpcd-$interface.pid ]]; then + dhcpcd -qk $interface || return 1 + else + ip addr flush dev $interface || return 1 + fi + ip link set dev $interface down || return 1 fi - - ip link set dev $interface down || return 1 } ifup() { |