diff options
Diffstat (limited to 'net-scripts/net.modules.d/udhcpc')
-rw-r--r-- | net-scripts/net.modules.d/udhcpc | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/net-scripts/net.modules.d/udhcpc b/net-scripts/net.modules.d/udhcpc index 25596c5..131231e 100644 --- a/net-scripts/net.modules.d/udhcpc +++ b/net-scripts/net.modules.d/udhcpc @@ -10,18 +10,14 @@ udhcpc() { LC_ALL=C /sbin/udhcpc "$@" } -# char* udhcpc_provides(void) -# -# Returns a string to change module definition for starting up -udhcpc_provides() { - echo "dhcp" -} - # void udhcpc_depend(void) # # Sets up the dependancies for the module udhcpc_depend() { after interface + provide dhcp + functions interface_exists interface_get_address + variables udhcpc dhcp } # bool udhcpc_check_installed(void) @@ -33,29 +29,6 @@ udhcpc_check_installed() { return 1 } -# bool udhcpc_check_depends(void) -# -# Checks to see if we have the needed functions -udhcpc_check_depends() { - local f - - for f in interface_exists interface_get_address; do - [[ $( type -t "${f}" ) == "function" ]] && continue - eerror "udhcpc: missing required function ${f}\n" - return 1 - done - - return 0 -} - -# char* udhcpc_get_vars(char *interface) -# -# Returns a string spaced with possible user set -# configuration variables -udhcpc_get_vars() { - echo "udhcpc_$1 dhcp_$1" -} - # bool udhcpc_stop(char *iface) # # Stops udhcpc running on an interface @@ -63,7 +36,6 @@ udhcpc_get_vars() { udhcpc_stop() { local iface="$1" pidfile="/var/run/udhcpc-$1.pid" d - udhcpc_check_installed || return 0 [[ ! -f ${pidfile} ]] && return 0 ebegin "Stopping udhcpc on ${iface}" @@ -99,7 +71,7 @@ udhcpc_start() { interface_exists "${iface}" true || return 1 - local ifvar=$( bash_variable "${iface}" ) opts hostname + local ifvar=$( bash_variable "${iface}" ) opts eval opts=\"\$\{udhcpc_${ifvar}\}\" eval d=\" \$\{dhcp_${ifvar}\} \" @@ -107,10 +79,9 @@ udhcpc_start() { if [[ ${d} != *" nosendhost "* ]]; then if [[ ! " ${opts}" =~ " -([hH] |-hostname=)" ]]; then - local hostname=$( hostname ) - [[ -n ${hostname} && ${hostname} != "(none)" \ - && ${hostname} != "localhost" ]] \ - && opts="${opts} --hostname=${hostname}" + local hname=$( hostname ) + [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ + && opts="${opts} --hostname=${hname}" fi fi @@ -124,7 +95,8 @@ udhcpc_start() { if [[ -f ${cachefile} ]]; then if [[ " ${opts}" != *" --request="* && " ${opts} " != *" -r "* ]]; then local x=$( < "${cachefile}" ) - [[ -n ${x} ]] && opts="${opts} --request=${x}" + # Check for a valid ip + [[ ${x} == *.*.*.* ]] && opts="${opts} --request=${x}" fi fi @@ -136,9 +108,9 @@ udhcpc_start() { fi x=$( eval udhcpc ${opts} --now --pidfile="${pidfile}" \ - --interface="${iface}" \ - --script="${MODULES_DIR}/helpers.d/udhcpc-wrapper" 2>&1 \ - | egrep -v '^info,' ) + --interface="${iface}" \ + --script="${MODULES_DIR}/helpers.d/udhcpc-wrapper" 2>&1 \ + | egrep -v '^info,' ) # We just check the last 5 letters [[ ${x:((${#x} - 5)):5} == "bound" ]] eend "$?" "${x}" || return 1 |