/[baselayout]/trunk/net.Linux/udhcpc.sh
Gentoo

Contents of /trunk/net.Linux/udhcpc.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2648 - (show annotations) (download) (as text)
Mon Apr 23 17:19:43 2007 UTC (7 years, 4 months ago) by uberlord
File MIME type: text/x-sh
File size: 2339 byte(s)
Fix udhcpc for releasing
1 # Copyright 2004-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 udhcpc_depend() {
5 program start /sbin/udhcpc
6 after interface
7 provide dhcp
8 }
9
10 _config_vars="$_config_vars dhcp udhcpc"
11
12 udhcpc_start() {
13 local args= opt= opts= pidfile="/var/run/udhcpc-${IFACE}.pid"
14 local sendhost=true cachefile="/var/cache/udhcpc-${IFACE}.lease"
15
16 eval args=\$udhcpc_${IFVAR}
17
18 # Get our options
19 eval opts=\$dhcp_${IFVAR}
20 [ -z "${opts}" ] && opts=${dhcp}
21
22 # Map some generic options to dhcpcd
23 for opt in ${opts} ; do
24 case "${opt}" in
25 nodns) args="${args} --env PEER_DNS=no" ;;
26 nontp) args="${args} --env PEER_NTP=no" ;;
27 nogateway) args="${args} --env PEER_ROUTERS=no" ;;
28 nosendhost) sendhost=false;
29 esac
30 done
31
32 [ "${metric:-0}" != "0" ] && args="${args} --env IF_METRIC=${metric}"
33
34 ebegin "Running udhcpc"
35
36 # Try and load the cache if it exists
37 if [ -f "${cachefile}" ]; then
38 case "$ {args} " in
39 *" --request="*|*" -r "*) ;;
40 *)
41 local x=$(cat "${cachefile}")
42 # Check for a valid ip
43 case "${x}" in
44 *.*.*.*) args="${args} --request=${x}" ;;
45 esac
46 ;;
47 esac
48 fi
49
50 case " ${args} " in
51 *" --quit "*|*" -q "*) x="/sbin/udhcpc" ;;
52 *) x="start-stop-daemon --start --exec /sbin/udhcpc \
53 --pidfile \"${pidfile}\" --" ;;
54 esac
55
56 case " ${args} " in
57 *" --hosname="*|*" -h "*|*" -H "*) ;;
58 *)
59 if ${sendhost} ; then
60 local hname="$(hostname)"
61 if [ "${hname}" != "(none)" ] && [ "${hname}" != "localhost" ]; then
62 args="${args} --hostname='${hname}'"
63 fi
64 fi
65 ;;
66 esac
67
68 eval "${x}" "${args}" --interface="${IFACE}" --now \
69 --script="${RC_LIBDIR}"/sh/udhcpc.sh \
70 --pidfile="${pidfile}" >/dev/null
71 eend $? || return 1
72
73 _show_address
74 return 0
75 }
76
77 udhcpc_stop() {
78 local pidfile="/var/run/udhcpc-${IFACE}.pid" opts=
79 [ ! -f "${pidfile}" ] && return 0
80
81 # Get our options
82 eval opts=\$dhcp_${IFVAR}
83 [ -z "${opts}" ] && opts=${dhcp}
84
85 ebegin "Stopping udhcpc on ${IFACE}"
86 case " ${opts} " in
87 *" release "*)
88 start-stop-daemon --stop --quiet --oknodo --signal USR2 \
89 --exec /sbin/udhcpc --pidfile "${pidfile}"
90 if [ -f /var/cache/udhcpc-"${IFACE}".lease ] ; then
91 rm -f /var/cache/udhcpc-"${IFACE}".lease
92 fi
93 ;;
94 esac
95
96 start-stop-daemon --stop --exec /sbin/udhcpc --pidfile "${pidfile}"
97 eend $?
98 }
99
100 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20