/[baselayout]/trunk/net-scripts/net.modules.d/pump
Gentoo

Contents of /trunk/net-scripts/net.modules.d/pump

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1753 - (show annotations) (download)
Fri Dec 9 15:08:06 2005 UTC (9 years ago) by uberlord
File size: 2723 byte(s)
Remove nasty undocumented backgrounding as we now support
ifplugd, netplug and wpa_supplicant-0.4.x which do much better jobs.
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 # void pump_depend(void)
14 #
15 # Sets up the dependancies for the module
16 pump_depend() {
17 after interface
18 provide dhcp
19 functions interface_exists interface_get_address
20 variables pump dhcp
21 }
22
23 # bool pump_check_installed(void)
24 #
25 # Returns 1 if pump is installed, otherwise 0
26 pump_check_installed() {
27 [[ -x /sbin/pump ]] && return 0
28 ${1:-false} && eerror "For DHCP (pump) support, emerge net-misc/pump"
29 return 1
30 }
31
32 # bool pump_stop(char *iface)
33 #
34 # Stop pump on an interface
35 # Return 0 if pump is not running or we stop it successfully
36 # Otherwise 1
37 pump_stop() {
38 local iface="$1" count e
39
40 # We check for a pump process first as querying for status
41 # causes pump to spawn a process
42 pidof /sbin/pump &>/dev/null || return 0
43
44 # Check that pump is running on the interface
45 pump --status --interface "${iface}" 2>/dev/null \
46 | grep -q "^Device ${iface}" || return 0
47
48 # Pump always releases the lease
49 ebegin "Stopping pump on ${iface}"
50 pump --release --interface "${iface}"
51 eend $? "Failed to stop pump"
52 }
53
54 # bool pump_start(char *iface)
55 #
56 # Start pump on an interface by calling pumpcd $iface $options
57 #
58 # Returns 0 (true) when a dhcp address is obtained, otherwise
59 # the return value from pump
60 pump_start() {
61 local iface="$1" opts d ifvar=$( bash_variable "$1" ) search
62
63 interface_exists "${iface}" true || return 1
64
65 opts="pump_${ifvar}"
66 opts="${!opts}"
67
68 # Map some generic options to pump
69 d="dhcp_${ifvar}"
70 d=" ${!d} "
71 [[ ${d} == " " ]] && d=" ${dhcp} "
72 [[ ${d} == *" nodns "* ]] && opts="${opts} --no-dns"
73 [[ ${d} == *" nogateway "* ]] && opts="${opts} --no-gateway"
74 [[ ${d} == *" nontp "* ]] && opts="${opts} --no-ntp"
75
76 search="dns_search_${ifvar}"
77 [[ -n ${!search} ]] && opts="${opts} --search-path='"${!search}"'"
78
79 # Add our route metric
80 metric="metric_${ifvar}"
81 [[ -n ${!metric} ]] && opts="${opts} --route-metric ${!metric}"
82
83 [[ ! -d "${statedir}/${iface}" ]] && mkdir -m 0755 -p "${statedir}/${iface}"
84
85 opts="${opts} --win-client-ident --etc-dir=${statedir}/${iface}"
86 opts="${opts} --script \"${svclib}/net.modules.d/helpers.d/pump-wrapper\""
87 opts="${opts} --keep-up --interface ${iface}"
88
89 # Bring up DHCP for this interface (or alias)
90 ebegin "Running pump"
91 eval pump "${opts}"
92 eend $? || return $?
93
94 # pump succeeded, show address retrieved
95 local addr=$( interface_get_address "${iface}" )
96 einfo "${iface} received address ${addr}"
97
98 return 0
99 }
100
101 # vim:ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20