Line 0
Link Here
|
|
|
1 |
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name> |
2 |
# Released under the 2-clause BSD license. |
3 |
|
4 |
dhclientv6_depend() |
5 |
{ |
6 |
after interface |
7 |
program start /sbin/dhclient |
8 |
provide dhcpv6 |
9 |
} |
10 |
|
11 |
_config_vars="$_config_vars dhcp dhclient dhcpv6 dhclientv6" |
12 |
|
13 |
dhclientv6_start() |
14 |
{ |
15 |
local args= opt= opts= pidfile="/var/run/dhclientv6-${IFACE}.pid" |
16 |
local sendhost=true dconf= |
17 |
|
18 |
# Get our options |
19 |
# These options only work in Gentoo, and maybe RedHat |
20 |
eval args=\$dhclientv6_${IFVAR} |
21 |
[ -z "${args}" ] && eval args=\$dhclient_${IFVAR} |
22 |
eval opts=\$dhcpv6_${IFVAR} |
23 |
[ -z "${opts}" ] && opts=${dhcpv6} |
24 |
[ -z "${opts}" ] && eval opts=\$dhcp_${IFVAR} |
25 |
[ -z "${opts}" ] && opts=${dhcp} |
26 |
|
27 |
for opt in ${opts}; do |
28 |
case "${opt}" in |
29 |
nodns) args="${args} -e PEER_DNS=no";; |
30 |
nontp) args="${args} -e PEER_NTP=no";; |
31 |
nogateway) args="${args} -e PEER_ROUTERS=no";; |
32 |
nosendhost) sendhost=false;; |
33 |
esac |
34 |
done |
35 |
|
36 |
# Add our route metric |
37 |
[ "${metric:-0}" != "0" ] && args="${args} -e IF_METRIC=${metric}" |
38 |
|
39 |
if ${sendhost}; then |
40 |
local hname="$(hostname)" |
41 |
if [ "${hname}" != "(none)" -a "${hname}" != "localhost" ]; then |
42 |
dhconf="${dhconf} interface \"${IFACE}\" {" |
43 |
dhconf="${dhconf} send fqdn.fqdn \"${hname}\";" |
44 |
dhconf="${dhconf} send fqdn.encoded on;" |
45 |
dhconf="${dhconf} send fqdn.server-update on;" |
46 |
dhconf="${dhconf} send fqdn.no-client-update on;" |
47 |
dhconf="${dhconf}}" |
48 |
fi |
49 |
fi |
50 |
|
51 |
# Bring up DHCP for this interface |
52 |
ebegin "Running dhclient -6" |
53 |
echo "${dhconf}" | start-stop-daemon --start --exec /sbin/dhclient \ |
54 |
--pidfile "${pidfile}" \ |
55 |
-- -6 ${args} -q -1 -pf "${pidfile}" "${IFACE}" |
56 |
eend $? || return 1 |
57 |
|
58 |
_show_address6 |
59 |
return 0 |
60 |
} |
61 |
|
62 |
dhclientv6_stop() |
63 |
{ |
64 |
local pidfile="/var/run/dhclientv6-${IFACE}.pid" opts= |
65 |
[ ! -f "${pidfile}" ] && return 0 |
66 |
|
67 |
# Get our options |
68 |
if [ -x /sbin/dhclient ]; then |
69 |
eval opts=\$dhcp_${IFVAR} |
70 |
[ -z "${opts}" ] && opts=${dhcp} |
71 |
fi |
72 |
|
73 |
ebegin "Stopping dhclient -6 on ${IFACE}" |
74 |
case " ${opts} " in |
75 |
*" release "*) dhclient -6 -q -r -pf "${pidfile}" "${IFACE}";; |
76 |
*) |
77 |
start-stop-daemon --stop --quiet \ |
78 |
--exec /sbin/dhclient --pidfile "${pidfile}" |
79 |
;; |
80 |
esac |
81 |
eend $? |
82 |
} |