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

Contents of /branches/baselayout-1_12/net-scripts/net.modules.d/pump

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1302 - (show annotations) (download)
Thu Jul 14 16:29:45 2005 UTC (9 years, 2 months ago) by uberlord
File size: 3523 byte(s)
New pump and dhcpcd helpers as pump now does everything it should - weeeeee
1 #!/bin/bash
2 # Copyright (c) 2004-2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
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_exists 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
62 # Return 0 if pump is not running or we stop it successfully
63 # Otherwise 1
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 pidof /sbin/pump &>/dev/null || return 0
72
73 # Check that pump is running on the interface
74 pump --status --interface "${iface}" 2>/dev/null \
75 | grep -q "^Device ${iface}" || return 0
76
77 # Pump always releases the lease
78 ebegin "Stopping pump on ${iface}"
79 pump --release --keep-up --interface "${iface}"
80 eend $? "Failed to stop pump"
81 return $?
82 }
83
84 # bool pump_start(char *iface)
85 #
86 # Start pump on an interface by calling pumpcd $iface $options
87 #
88 # Returns 0 (true) when a dhcp address is obtained, otherwise
89 # the return value from pump
90 pump_start() {
91 local iface="$1" opts d ifvar=$( bash_variable "$1" ) search
92
93 interface_exists "${iface}" true || return 1
94
95 eval opts=\" \$\{pump_${ifvar}\} \"
96
97 # Map some generic options to pump
98 eval d=\" \$\{dhcp_${ifvar}\} \"
99 [[ ${d} == " " ]] && d=" ${dhcp} "
100 [[ ${d} == *" nodns "* ]] && opts="${opts} --no-dns"
101 [[ ${d} == *" nogateway "* ]] && opts="${opts} --no-gateway"
102 [[ ${d} == *" nontp "* ]] && opts="${opts} --no-ntp"
103
104 eval search=\"\$\{dns_search_path_${ifvar}\}\"
105 [[ -n ${search} ]] && opts="${opts} --search-path='"${search}"'"
106
107 # Add our route metric
108 eval metric=\"\$\{metric_${ifvar}\}\"
109 [[ -n ${metric} ]] && opts="${opts} --route-metric ${metric}"
110
111 [[ ! -d "${statedir}/${iface}" ]] && mkdir -p "${statedir}/${iface}"
112
113 opts="${opts} --win-client-ident --etc-dir=${statedir}/${iface}"
114 opts="${opts} --script /lib/rcscripts/net.modules.d/helpers.d/pump-wrapper"
115 opts="${opts} --interface ${iface}"
116
117 # Bring up DHCP for this interface (or alias)
118 ebegin "Running pump"
119
120 if [[ ${background} == "yes" ]]; then
121 eval pump ${opts} &
122 eend 0
123 go_background
124 fi
125
126 eval pump ${opts}
127 eend $? || return $?
128
129 # pump succeeded, show address retrieved
130 local addr=$( interface_get_address "${iface}" )
131 einfo "${iface} received address ${addr}"
132
133 return 0
134 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20