/[baselayout]/branches/rc-scripts-1_6/net-scripts/net.modules.d/pump
Gentoo

Contents of /branches/rc-scripts-1_6/net-scripts/net.modules.d/pump

Parent Directory Parent Directory | Revision Log Revision Log


Revision 757 - (show annotations) (download)
Mon Dec 6 15:46:18 2004 UTC (14 years ago) by agriffis
File size: 3595 byte(s)
Merge updates from HEAD

1 # Pump module for net-scripts
2 # Version 1.0.6
3 # Copyright (c) 2004 Gentoo Foundation
4 # Distributed under the terms of the GNU General Public License V2
5 # Contributed by Roy Marples (uberlord@gentoo.org)
6
7 # Fix any potential localisation problems
8 # Note that LC_ALL trumps LC_anything_else according to locale(7)
9 pump() {
10 LC_ALL=C /sbin/pump "$@"
11 }
12
13 # char* pump_provides(void)
14 #
15 # Returns a string to change module definition for starting up
16 pump_provides() {
17 echo "dhcp"
18 }
19
20 # void pump_depend(void)
21 #
22 # Sets up the dependancies for the module
23 pump_depend() {
24 after interface
25 }
26
27 # bool pump_check_installed(void)
28 #
29 # Returns 1 if pump is installed, otherwise 0
30 pump_check_installed() {
31 [[ -x /sbin/pump ]] && return 0
32 ${1:-false} && eerror "For DHCP (pump) support, emerge net-misc/pump"
33 return 1
34 }
35
36 # bool pump_check_depends(void)
37 #
38 # Checks to see if we have the needed functions
39 pump_check_depends() {
40 local f
41
42 for f in interface_variable interface_device interface_is_up interface_get_address; do
43 [[ $( type -t ${f} ) == function ]] && continue
44 eerror "pump: missing required function ${f}\n"
45 return 1
46 done
47
48 return 0
49 }
50
51 # char* pump_get_vars(char *interface)
52 #
53 # Returns a string spaced with possible user set
54 # configuration variables
55 pump_get_vars() {
56 echo "pump_${1} dhcp_${1}"
57 }
58
59 # bool pump_stop(char *iface)
60 #
61 # Stop pump on an interface by calling pumpcd -z $iface
62 #
63 # Always returns 0
64 pump_stop() {
65 local iface=${1} count e
66
67 pump_check_installed || return 0
68
69 # We check for a pump process first as querying for status
70 # causes pump to spawn a process
71 ps -C pump &>/dev/null || return 0
72
73 e=$( pump --status --interface ${iface} 2>${devnull} | grep ${iface})
74 [[ -z ${e} ]] && return 1
75
76 ebegin "Stopping pump on ${iface}"
77 for ((count = 0; count < 9; count = count + 1)); do
78 e=$( pump --release --interface ${iface} 2>${devnull} )
79 [[ -z ${e} ]] && break
80 sleep 1
81 done
82 [[ ${count} -lt 9 ]]
83 eend $? "Timed out"
84
85 return 0 # we did *attempt* to stop pump
86 }
87
88 # bool pump_start(char *iface)
89 #
90 # Start pump on an interface by calling pumpcd $iface $options
91 #
92 # Returns 0 (true) when a dhcp address is obtained, otherwise
93 # the return value from pump
94 pump_start() {
95 local iface=${1} opts hostname dhcp
96 local ifvar=$( interface_variable ${iface} )
97
98 interface_exists ${iface} true || return 1
99
100 # Check that iface was not brought up by the kernel ...
101 local check=$( interface_device ${iface} )
102 if [[ ${check} == ${iface} ]] && interface_is_up ${iface} true ; then
103 einfo "Keeping kernel configuration for ${iface}"
104 return 0
105 fi
106
107 eval opts=\"\$\{pump_${ifvar}\}\"
108
109 # Map some generic options to pump
110 eval dhcp=\" \$\{dhcp_${ifvar}\} \"
111 [[ ${dhcp} == *' nodns '* ]] && opts="${opts} --no-dns"
112
113 # We transmit the hostname by default
114 if [[ ${opts} != *'-h '* && ${opts} != '*--hostname='* ]]; then
115 hostname=$( hostname )
116 [[ -n ${hostname} && ${hostname} != "(none)" && ${hostname} != localhost ]] \
117 && opts="--hostname=${hostname} ${opts}"
118 fi
119
120 # Bring up DHCP for this interface (or alias)
121 ebegin "Running pump"
122 pump ${opts} --win-client-ident --interface ${iface} 2>${devnull}
123 eend $? || return $?
124
125 # pump succeeded, show address retrieved
126 local addr=$( interface_get_address ${iface} )
127 einfo "${iface} received address ${addr}"
128
129 eval peer=\"\$\{dhcp_ntp_${iface}\}\"
130 [[ -z ${peer} ]] && eval peer=\"\$\{dhcp_ntp\}\"
131 if [[ ${peer} != no ]]; then
132 export ntpsrv=$( pump -i ${iface} --status 2>/dev/null | awk '/Ntpservers/ {print $2}' 2>/dev/null )
133 source ${MODULES_DIR}/helpers.d/config-system
134 config_system
135 fi
136
137 return 0
138 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20