diff options
author | Christian Heim <phreak@gentoo.org> | 2006-02-27 13:15:18 +0000 |
---|---|---|
committer | Christian Heim <phreak@gentoo.org> | 2006-02-27 13:15:18 +0000 |
commit | 8eb30724c1a19a754fe444da5e4fa990d953b49a (patch) | |
tree | 42141954490bb973cfc7d47ea1599fe33e16360b /net-scripts/net.modules.d/helpers.d | |
parent | Merging baselayout r1924 (diff) | |
download | baselayout-vserver-8eb30724c1a19a754fe444da5e4fa990d953b49a.tar.gz baselayout-vserver-8eb30724c1a19a754fe444da5e4fa990d953b49a.tar.bz2 baselayout-vserver-8eb30724c1a19a754fe444da5e4fa990d953b49a.zip |
Merging r1928
svn path=/baselayout-vserver/trunk/; revision=265
Diffstat (limited to 'net-scripts/net.modules.d/helpers.d')
-rwxr-xr-x | net-scripts/net.modules.d/helpers.d/dhclient-wrapper | 2 | ||||
-rwxr-xr-x | net-scripts/net.modules.d/helpers.d/dhcp | 32 | ||||
-rw-r--r-- | net-scripts/net.modules.d/helpers.d/dhcp-state | 10 | ||||
-rwxr-xr-x | net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper | 14 | ||||
-rw-r--r-- | net-scripts/net.modules.d/helpers.d/functions | 134 | ||||
-rw-r--r-- | net-scripts/net.modules.d/helpers.d/module-loader | 14 | ||||
-rw-r--r-- | net-scripts/net.modules.d/helpers.d/pppd-wrapper | 12 | ||||
-rwxr-xr-x | net-scripts/net.modules.d/helpers.d/pump-wrapper | 4 | ||||
-rwxr-xr-x | net-scripts/net.modules.d/helpers.d/udhcpc-wrapper | 6 |
9 files changed, 99 insertions, 129 deletions
diff --git a/net-scripts/net.modules.d/helpers.d/dhclient-wrapper b/net-scripts/net.modules.d/helpers.d/dhclient-wrapper index 08a9433..7dd1154 100755 --- a/net-scripts/net.modules.d/helpers.d/dhclient-wrapper +++ b/net-scripts/net.modules.d/helpers.d/dhclient-wrapper @@ -17,7 +17,7 @@ case "${reason}" in MEDIUM) exit 0 ;; esac -if [[ -z ${action} ]]; then +if [[ -z ${action} ]] ; then echo "dhclient sent an unknown action ${reason}!" >&2 exit 1 fi diff --git a/net-scripts/net.modules.d/helpers.d/dhcp b/net-scripts/net.modules.d/helpers.d/dhcp index ceb2d60..6a315af 100755 --- a/net-scripts/net.modules.d/helpers.d/dhcp +++ b/net-scripts/net.modules.d/helpers.d/dhcp @@ -22,8 +22,8 @@ case "${action}" in interface_del_addresses "${interface}" true service_started "${service}" && mark_service_inactive "${service}" remove_state "${interface}" - if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then - best_interface=$( select_best_interface ) + if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then + best_interface="$(select_best_interface)" apply_state "${best_interface}" fi echo "${action}" @@ -44,19 +44,19 @@ esac macnet_pre_start "${interface}" 1>/dev/null # Map wireless ESSID variables to interface variables -if [[ -n ${wireless_module} ]]; then +if [[ -n ${wireless_module} ]] ; then if wireless_exists "${interface}" ; then essidnet_pre_start "${interface}" 1>/dev/null fi fi # Calculate the metric for our routes -ifvar=$( bash_variable "${interface}" ) +ifvar="$(bash_variable "${interface}")" metric="metric_${ifvar}" metric="${!metric}" -if [[ -z ${metric} ]]; then - if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then - metric=$( calculate_metric "${interface}" ) +if [[ -z ${metric} ]] ; then + if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then + metric="$(calculate_metric "${interface}")" else metric="0" fi @@ -66,36 +66,32 @@ fi # Configure our IP address ip="${ip// /}" subnet="${subnet// /}" -cidr=$( netmask2cidr "${subnet}" ) +cidr="$(netmask2cidr "${subnet}")" broadcast="${broadcast// /}" [[ -n ${broadcast} ]] && broadcast="broadcast ${broadcast}" # If we don't have our address then we flush it and then add our new one -curip=$( interface_get_address "${interface}" ) +curip="$(interface_get_address "${interface}")" if [[ ${curip} != "${ip}/${cidr}" ]] ; then # Just remove IPv4 / inet addresses interface_del_addresses "${interface}" true interface_add_address "${interface}" "${ip}/${cidr}" "${broadcast}" fi -# Store the address in a cache for future usage -echo "${ip}" > "/var/cache/dhcp-${interface}.lease" -chmod 600 "/var/cache/dhcp-${interface}.lease" - d="dhcp_${ifvar}" d=" ${!d} " [[ ${d} == " " ]] && d=" ${dhcp} " # Configure our default route - we only have 1 default route -if [[ ${d} != *" nogateway "* ]]; then +if [[ ${d} != *" nogateway "* ]] ; then for r in ${routers}; do interface_default_route "${interface}" "${r}" "${metric:-0}" && break done fi # Configure our hostname - but only if we need it -if [[ -n ${hostname} ]]; then - x=$( hostname ) +if [[ -n ${hostname} ]] ; then + x="$(hostname)" [[ ${x} == "(none)" || ${x} == "localhost" ]] && hostname "${hostname}" fi @@ -108,8 +104,8 @@ fi [[ ${d} != *" nontp "* ]] && system_ntp "${interface}" [[ ${d} != *" nonis "* ]] && system_nis "${interface}" -if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then - best_interface=$( select_best_interface ) +if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then + best_interface="$(select_best_interface)" apply_state "${best_interface}" else apply_state "${interface}" diff --git a/net-scripts/net.modules.d/helpers.d/dhcp-state b/net-scripts/net.modules.d/helpers.d/dhcp-state index c5de21f..0b5d3c7 100644 --- a/net-scripts/net.modules.d/helpers.d/dhcp-state +++ b/net-scripts/net.modules.d/helpers.d/dhcp-state @@ -6,22 +6,22 @@ . "${svclib}/sh/rc-services.sh" . "${svclib}/net.modules.d/helpers.d/functions" -conf=$(add_suffix "/etc/conf.d/net") +conf="$(add_suffix /etc/conf.d/net)" [[ -e ${conf} ]] && source "${conf}" service="net.${interface}" -if [[ ${action} != "up" ]]; then +if [[ ${action} != "up" ]] ; then service_started "${service}" && mark_service_inactive "${service}" remove_state "${interface}" false else service_inactive "${service}" && mark_service_started "${service}" fi -if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then - best_interface=$( select_best_interface ) +if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then + best_interface="$(select_best_interface)" apply_state "${best_interface}" -elif [[ ${action} == "up" ]]; then +elif [[ ${action} == "up" ]] ; then apply_state "${interface}" fi diff --git a/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper b/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper index 5769103..ce86a3d 100755 --- a/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper +++ b/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper @@ -7,7 +7,7 @@ interface="${1##*/dhcpcd-}" interface="${interface%%.info}" -if [[ $2 != "up" && $2 != "new" ]]; then +if [[ $2 != "up" && $2 != "new" ]] ; then action="down" else action="up" @@ -20,24 +20,24 @@ fi macnet_pre_start "${interface}" 1>/dev/null # Map wireless ESSID variables to interface variables -if [[ -n ${wireless_module} ]]; then +if [[ -n ${wireless_module} ]] ; then if wireless_exists "${interface}" ; then essidnet_pre_start "${interface}" 1>/dev/null fi fi # Add any search paths if we have any defined -ifvar=$( bash_variable "${interface}" ) +ifvar="$(bash_variable "${interface}")" -if [[ ${action} == "up" ]]; then +if [[ ${action} == "up" ]] ; then d="dhcp_${ifvar}" d=" ${!d} " [[ ${d} == " " ]] && d=" ${dhcp} " resolv="${statedir}/${interface}/resolv.conf" - if [[ ${d} != *" nodns "* ]]; then + if [[ ${d} != *" nodns "* ]] ; then search="dns_search_${ifvar}" - if [[ -n ${!search} ]]; then + if [[ -n ${!search} ]] ; then tmp="${resolv}.$$" egrep -v "^[ \t]*(search|domain)[ \t]*" "${resolv}" > "${tmp}" echo "search ${!search}" >> "${tmp}" @@ -51,7 +51,7 @@ fi # As we override the -c option, we need to call the specified script ourself opts="dhcpcd_${ifvar}" exe="${!opts##* -c }" -if [[ -n ${exe} && ${exe} != "${!opts}" ]]; then +if [[ -n ${exe} && ${exe} != "${!opts}" ]] ; then exe="${exe%% *}" else exe="/etc/dhcpc/dhcpcd.exe" diff --git a/net-scripts/net.modules.d/helpers.d/functions b/net-scripts/net.modules.d/helpers.d/functions index 52f3da1..ff67435 100644 --- a/net-scripts/net.modules.d/helpers.d/functions +++ b/net-scripts/net.modules.d/helpers.d/functions @@ -60,23 +60,23 @@ remove_state() { apply_state() { local iface="$1" - if [[ -z ${iface} ]]; then - iface=$( select_best_interface ) + if [[ -z ${iface} ]] ; then + iface="$(select_best_interface)" [[ -z ${iface} ]] && return fi local d="${statedir}/${iface}" - if [[ -d ${d} ]]; then - local files=$( ls "${d}" ) + if [[ -d ${d} ]] ; then + local files="$(ls "${d}")" if [[ -n ${files} ]] ; then - if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then + if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then cp -pPR "${d}"/* "${netdir}" local file for file in ${files} ; do # Skip .sv files [[ ${file} == *".sv" ]] && continue - local link=$( readlink "/etc/${file}" 2>/dev/null ) - if [[ ${link} != "${netdir}/${file}" ]]; then + local link="$(readlink "/etc/${file}" 2>/dev/null)" + if [[ ${link} != "${netdir}/${file}" ]] ; then [[ -e "/etc/${file}" ]] && rm -f "/etc/${file}" ln -snf "${netdir}/${file}" "/etc/${file}" fi @@ -99,8 +99,9 @@ order_interfaces() { local ifaces extra ${1:-false} && extra=' && $2=="00000000"' - ifaces=$(awk '{if (NR>1 && $1!="lo"'"${extra}"') print $7, $1}' /proc/net/route \ - | sort -n | cut -d' ' -f2 | uniq) + ifaces="$(awk '{if (NR>1 && $1!="lo"'"${extra}"') print $7, $1}' \ + /proc/net/route \ + | sort -n | cut -d' ' -f2 | uniq)" # Append lo if it's up if ! ${1:-false} ; then @@ -140,16 +141,18 @@ merge_resolv() { j=0 for (( i=0; i<${#ifaces[@]}; i++ )); do f="${statedir}/${ifaces[i]}/resolv.conf" - srvs[i]=$( sed -n -e 's/^[ \t]*nameserver[ \t]*\([^#]*\).*/\1/p' "${f}" \ - | sed 2q ) + srvs[i]="$(sed -n -e 's/^[ \t]*nameserver[ \t]*\([^#]*\).*/\1/p' \ + "${f}" | sed 2q)" - search[i]=$( sed -n -e 's/^[ \t]*\(domain\|search\)[ \t]*\([^#]*\).*/\2/p' \ - "${f}" | sed -e '$!d' ) + search[i]="$(sed -n -e 's/^[ \t]*\(domain\|search\)[ \t]*\([^#]*\).*/\2/p' \ + "${f}" | sed -e '$!d')" - opts[i]=$( sed -n -e 's/^[ \t]*options[ \t]*\([^#]*\).*/\1#/p;' "${f}" | xargs ) - sortlist[i]=$( sed -n -e 's/^[ \t]*sortlist[ \t]*\([^#]*\).*/\1/p' "${f}" ) + opts[i]="$(sed -n -e 's/^[ \t]*options[ \t]*\([^#]*\).*/\1#/p;' "${f}" \ + | xargs )" + sortlist[i]="$(sed -n -e 's/^[ \t]*sortlist[ \t]*\([^#]*\).*/\1/p' \ + "${f}")" - if [[ -z ${srvs[i]} && -z ${opts[i]} && -z ${sortlist[i]} && -z ${search[i]} ]]; then + if [[ -z ${srvs[i]} && -z ${opts[i]} && -z ${sortlist[i]} && -z ${search[i]} ]] ; then unset srvs[i] unset search[i] unset opts[i] @@ -171,7 +174,7 @@ merge_resolv() { # Add interface primary nameservers for (( i=0;i<${#srvs[@]}; i++ )); do local -a n=( ${srvs[i]} ) - if [[ " ${new_srvs} " != *" ${n[0]} "* ]]; then + if [[ " ${new_srvs} " != *" ${n[0]} "* ]] ; then new_srvs="${new_srvs} ${n[0]}" # libc can only handle 3 name servers (( j++ )) @@ -180,11 +183,11 @@ merge_resolv() { done # Add interface secondary nameservers - if [[ ${j} -lt 3 ]]; then + if [[ ${j} -lt 3 ]] ; then for (( i=0;i<${#srvs[@]}; i++ )); do local -a n=( ${srvs[i]} ) [[ -z ${n[1]} ]] && continue - if [[ " ${new_srvs} " != *" ${n[1]} "* ]]; then + if [[ " ${new_srvs} " != *" ${n[1]} "* ]] ; then new_srvs="${new_srvs} ${n[1]}" # libc can only handle 3 name servers (( j++ )) @@ -195,7 +198,7 @@ merge_resolv() { local new_search n_search=0 for i in ${search[@]}; do - if [[ " ${new_search} " != *" ${i} "* ]]; then + if [[ " ${new_search} " != *" ${i} "* ]] ; then new_search="${new_search} ${i}" # libc limits us to 6 search domains (( n_search++ )) @@ -209,14 +212,14 @@ merge_resolv() { done # Remove duplicate options - new_opts=$( + new_opts="$( echo -e "${new_opts//\#/\n}" \ - | sort -u | sed -e 's/^/#/g' | xargs - ) + | sort -u | sed -e 's/^/#/g' | xargs \ + )" local new_sortlist n_sortlist=0 for i in ${sortlist[@]}; do - if [[ " ${new_sortlist} " != *" ${i} "* ]]; then + if [[ " ${new_sortlist} " != *" ${i} "* ]] ; then new_sortlist="${new_sortlist} ${i}" # libc limits us to 10 items (( n_sortlist++ )) @@ -231,8 +234,8 @@ merge_resolv() { for i in ${new_srvs[@]}; do echo "nameserver ${i}" >> "${f}" done - if [[ -n ${new_search} ]]; then - if [[ ${n_search} == "1" ]]; then + if [[ -n ${new_search} ]] ; then + if [[ ${n_search} == "1" ]] ; then echo "domain${new_search}" >> "${f}" else echo "search${new_search}" >> "${f}" @@ -284,7 +287,7 @@ merge_ntp() { echo -e "$@" | sort -u } - srvs=$( sort_unique ${srvs} ) + srvs="$(sort_unique ${srvs})" f="${netdir}/ntp.conf.$$" echo "# Generated by net-scripts for interfaces ${ifaces[@]}" > "${f}" @@ -325,7 +328,7 @@ select_best_interface() { local iface for iface in ${ifs[@]} ; do - if [[ -e "${statedir}/${iface}/resolv.conf" ]]; then + if [[ -e "${statedir}/${iface}/resolv.conf" ]] ; then echo "${iface}" return 0 fi @@ -343,20 +346,20 @@ calculate_metric() { local iface="$1" exclude='$1!="Iface" && $1!="lo"' # Have we already got a metric? - local m=$( awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \ - /proc/net/route ) - if [[ -n ${m} ]]; then + local m="$( awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \ + /proc/net/route )" + if [[ -n ${m} ]] ; then echo "${m}" return 0 fi - local itype=$( interface_type "${iface}" ) x i + local itype="$(interface_type "${iface}")" x i # If we're not a wireless device then exclude wireless from the # routing table so we stay < 1000 - if [[ -e /proc/net/wireless ]]; then + if [[ -e /proc/net/wireless ]] ; then if ! grep -q "^[ \t]*${iface}:[ \t]" /proc/net/wireless ; then - local i=$( sed -n -e 's/^[ \t]*\(.*\):.*/\1/p' /proc/net/wireless ) + local i="$(sed -n -e 's/^[ \t]*\(.*\):.*/\1/p' /proc/net/wireless)" for x in ${i} ; do exclude="${exclude} && "'$1'"!=\"${x}\"" done @@ -367,18 +370,18 @@ calculate_metric() { local ix="ppp|ippp" [[ ${itype} == "ppp" ]] && ix="ippp" [[ ${itype} == "ippp" ]] && ix="ppp" - i=$( sed -n -e 's/^[ ]*\('${ix}'[0-9]*\):.*$/\1/p' /proc/net/dev ) + i="$( sed -n -e 's/^[ ]*\('"${ix}"'[0-9]*\):.*$/\1/p' /proc/net/dev )" for x in ${i} ; do exclude="${exclude} && "'$1'"!=\"${x}\"" done - local m=$( awk "${exclude} { print "'$7'" }" /proc/net/route \ - | sort -rn | head -n 1 | cut -d' ' -f2 ) + local m="$( awk "${exclude} { print "'$7'" }" /proc/net/route \ + | sort -rn | head -n 1 | cut -d' ' -f2 )" m="${m:--1}" (( m ++ )) # If we're a wireless device then add 1000 so that wired interfaces take preference - if [[ -e /proc/net/wireless ]]; then + if [[ -e /proc/net/wireless ]] ; then grep -q "^[ \t]*${iface}:[ \t]" /proc/net/wireless && (( m+= 1000 )) fi @@ -397,7 +400,7 @@ netmask2cidr() { for i in ${1//./ }; do bin="" - while [[ ${i} != "0" ]]; do + while [[ ${i} != "0" ]] ; do bin=$[${i}%2]${bin} (( i=i>>1 )) done @@ -416,13 +419,13 @@ cidr2netmask() { (( octets=cidr/8 )) (( frac=cidr%8 )) - while [[ octets -gt 0 ]]; do + while [[ octets -gt 0 ]] ; do netmask="${netmask}.255" (( octets-- )) (( done++ )) done - if [[ ${done} -lt 4 ]]; then + if [[ ${done} -lt 4 ]] ; then for (( i=0; i<${frac}; i++ )); do (( sum+=cur )) (( cur/=2 )) @@ -430,7 +433,7 @@ cidr2netmask() { netmask="${netmask}.${sum}" (( done++ )) - while [[ ${done} -lt 4 ]]; do + while [[ ${done} -lt 4 ]] ; do netmask="${netmask}.0" (( done++ )) done @@ -452,10 +455,10 @@ ip_network() { [[ ${ip} != *.*.*.* ]] && return # If we didn't get parameter 2 then assume we have a CIDR - if [[ -z ${mask} ]]; then + if [[ -z ${mask} ]] ; then mask="${ip##*/}" [[ -z ${mask} || ${mask} == ${ip} ]] && return 1 - mask=$( cidr2netmask "${mask}" ) + mask="$(cidr2netmask "${mask}")" ip="${ip%%/*}" fi @@ -471,41 +474,6 @@ ip_network() { echo "${network}" } -# bool clean_pidfile(char *file) -# -# Removes the given pidfile if the process is not running -# Returns 1 if the process is still running otherwise 0 -clean_pidfile() { - local pidfile="$1" - - [[ ! -f ${pidfile} ]] && return 0 - local pid=$( < "${pidfile}" ) - - if [[ -n ${pid} ]]; then - local cmd="${pidfile##*/}" - cmd="${cmd%%-*}" - ps p "${pid}" 2>/dev/null | grep -q "${cmd}" && return 1 - fi - - rm -f "${pidfile}" - return 0 -} - -# bool process_finished(int pid, char* cmd) -# -# We wait for 10 seconds until the command ${cmd} -# stops running on the process ${pid} -process_finished() { - local i pid="$1" cmd="$2" secs="${3:-9}" - - for (( i=0; i<secs; i++ )); do - ps p "${pid}" 2>/dev/null | grep -q "${cmd}" || return 0 - sleep 1 - done - - return 1 -} - # bool is_function(char* name) # # Returns 0 if the given name is a shell function, otherwise 1 @@ -560,7 +528,7 @@ configure_variables() { local mod func x i local -a ivars ovars1 ovars2 - local ifvar=$( bash_variable "${iface}" ) + local ifvar="$(bash_variable "${iface}")" for mod in ${MODULES[@]}; do is_function ${mod}_variables || continue @@ -576,18 +544,18 @@ configure_variables() { } # Provide a wrapper for hostname if it's not available -if [[ -z $(type -p hostname) ]]; then +if [[ -z $(type -p hostname) ]] ; then hostname() { # Linux and *BSD seem to differ local kernel="kern" ctl="hostname" [[ $(uname) == "Linux" ]] && kernel="kernel" - if [[ $1 == "-y" || $1 == "--yp" || $1 == "nis" ]]; then + if [[ $1 == "-y" || $1 == "--yp" || $1 == "nis" ]] ; then ctl="domainname" shift fi - if [[ -n $1 ]]; then + if [[ -n $1 ]] ; then sysctl -q -w "${kernel}.${ctl}=$1" else sysctl -n "${kernel}.${ctl}" diff --git a/net-scripts/net.modules.d/helpers.d/module-loader b/net-scripts/net.modules.d/helpers.d/module-loader index fe6d1df..f978f68 100644 --- a/net-scripts/net.modules.d/helpers.d/module-loader +++ b/net-scripts/net.modules.d/helpers.d/module-loader @@ -12,7 +12,7 @@ MODULES_DIR="${svclib}/net.modules.d" conf="$(add_suffix /etc/conf.d/net)" [[ -e ${conf} ]] && source "${conf}" -conf="$(add_suffix /etc/conf.d/net.${interface})" +conf="$(add_suffix "/etc/conf.d/net.${interface}")" [[ -e ${conf} ]] && source "${conf}" # Create some dummy functions, so we can depend on a module @@ -25,9 +25,9 @@ functions() { return; } variables() { eval "${MODULE}_variables() { echo \"$*\"; }"; } # Guess which interface module to load - we prefer iproute2 -if [[ -x /sbin/ip ]]; then +if [[ -x /sbin/ip ]] ; then interface_module="iproute2" -elif [[ -x /sbin/ifconfig ]]; then +elif [[ -x /sbin/ifconfig ]] ; then interface_module="ifconfig" else echo "Can't find a known interface module" >&2 @@ -36,10 +36,10 @@ fi # iwconfig is the best bet for wireless - we use wpa_supplicant # only if we need to -if [[ -x /sbin/iwconfig ]]; then +if [[ -x /sbin/iwconfig ]] ; then wireless_module="iwconfig" elif [[ -x /sbin/wpa_supplicant \ - && -S "/var/run/wpa_supplicant/${interface}" ]]; then + && -S "/var/run/wpa_supplicant/${interface}" ]] ; then wireless_module="wpa_supplicant" fi @@ -51,7 +51,7 @@ MODULE="interface" ${interface_module}_depend function_wrap "${interface_module}" interface -if [[ -e "${MODULES_DIR}/macnet" ]]; then +if [[ -e "${MODULES_DIR}/macnet" ]] ; then . "${MODULES_DIR}/macnet" MODULE="macnet" macnet_depend @@ -61,7 +61,7 @@ fi MODULE="system" system_depend -if [[ -n ${wireless_module} ]]; then +if [[ -n ${wireless_module} ]] ; then . "${MODULES_DIR}/${wireless_module}" MODULE="${wireless_module}" ${wireless_module}_depend diff --git a/net-scripts/net.modules.d/helpers.d/pppd-wrapper b/net-scripts/net.modules.d/helpers.d/pppd-wrapper index 63a868a..c7f6f90 100644 --- a/net-scripts/net.modules.d/helpers.d/pppd-wrapper +++ b/net-scripts/net.modules.d/helpers.d/pppd-wrapper @@ -11,8 +11,8 @@ export IN_BACKGROUND="true" . "${svclib}/net.modules.d/helpers.d/module-loader" resolv="${statedir}/${interface}/resolv.conf" -if [[ ${action} == "up" ]]; then - if [[ -n ${DNS1} || -n ${DNS2} ]]; then +if [[ ${action} == "up" ]] ; then + if [[ -n ${DNS1} || -n ${DNS2} ]] ; then echo "# Generated by pppd for interface $1" > "${resolv}" chmod 0644 "${resolv}" [ -n ${DNS1} ] && echo "nameserver ${DNS1}" >> "${resolv}" @@ -20,12 +20,12 @@ if [[ ${action} == "up" ]]; then fi # Calculate the metric for our routes - ifvar=$( bash_variable "${interface}" ) + ifvar="$(bash_variable "${interface}")" metric="metric_${ifvar}" metric="${!metric}" - if [[ -z ${metric} ]]; then - if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then - metric=$( calculate_metric "${interface}" ) + if [[ -z ${metric} ]] ; then + if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then + metric="$(calculate_metric "${interface}")" else metric="0" fi diff --git a/net-scripts/net.modules.d/helpers.d/pump-wrapper b/net-scripts/net.modules.d/helpers.d/pump-wrapper index fec705c..981480d 100755 --- a/net-scripts/net.modules.d/helpers.d/pump-wrapper +++ b/net-scripts/net.modules.d/helpers.d/pump-wrapper @@ -11,14 +11,14 @@ interface="$2" . /sbin/functions.sh -if [[ ${action} == "up" ]]; then +if [[ ${action} == "up" ]] ; then . "${svclib}/net.modules.d/helpers.d/module-loader" # Map MAC address variables to interface variables macnet_pre_start "${interface}" 1>/dev/null # Map wireless ESSID variables to interface variables - if [[ -n ${wireless_module} ]]; then + if [[ -n ${wireless_module} ]] ; then if wireless_exists "${interface}" ; then essidnet_pre_start "${interface}" 1>/dev/null fi diff --git a/net-scripts/net.modules.d/helpers.d/udhcpc-wrapper b/net-scripts/net.modules.d/helpers.d/udhcpc-wrapper index 3edab95..9548d07 100755 --- a/net-scripts/net.modules.d/helpers.d/udhcpc-wrapper +++ b/net-scripts/net.modules.d/helpers.d/udhcpc-wrapper @@ -18,4 +18,10 @@ export nis_servers_${interface}="${nissrv}" . /sbin/functions.sh "${svclib}/net.modules.d/helpers.d/dhcp" "$@" +if [[ $? == 0 ]] && [[ $1 == "bound" || $1 == "renew" ]] ; then + # Store the address in a cache for future usage + echo "${ip// /}" > "/var/cache/udhcpc-${interface}.lease" + chmod 600 "/var/cache/udhcpc-${interface}.lease" +fi + # vim:ts=4 |