3
# $Id: macos,v 1.2 2008/11/03 23:32:12 dhankins Exp $
5
# automous run of this script will commit the DNS setting
8
if [ -x /usr/bin/logger ]; then
9
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
18
if [ "x${new_dhcp6_name_servers}" != x ]; then
19
( cat /dev/null > /var/run/resolv.conf.dhclient6 )
21
if [ $exit_status -ne 0 ]; then
22
$LOGGER "Unable to create /var/run/resolv.conf.dhclient6: Error $exit_status"
24
if [ "x${new_dhcp6_domain_search}" != x ]; then
25
( echo search ${new_dhcp6_domain_search} >> /var/run/resolv.conf.dhclient6 )
28
for nameserver in ${new_dhcp6_name_servers} ; do
29
if [ $exit_status -ne 0 ]; then
32
( echo nameserver ${nameserver} >> /var/run/resolv.conf.dhclient6 )
36
if [ $exit_status -eq 0 ]; then
44
# Try to commit /var/run/resolv.conf.dhclient6 contents to
45
# SystemConfiguration Dynamic Store
46
# Note this will be cleared by the next location change
47
commit_resolv_conf() {
48
if [ -f /var/run/resolv.conf.dhclient6 ]; then
49
if [ -x /usr/sbin/scutil ]; then
50
serviceID=`echo show State:/Network/Global/IPv6 | \
52
awk '/PrimaryService/ { print $3 }'`
54
if [ x$serviceID = x ]; then
55
$LOGGER "Can't find the primary IPv6 service"
57
tmp=`mktemp SC_dhclient6.XXXXXXXXXX`
58
echo list | /usr/sbin/scutil > /tmp/$tmp
59
grep -q State:/Network/Service/$serviceID/DNS /tmp/$tmp
61
if [ $grep_status -eq 0 ]; then
62
$LOGGER "DNS service already set in primary IPv6 service"
65
res=/var/run/resolv.conf.dhclient6
66
cp /dev/null /tmp/$tmp
67
grep -q '^nameserver' $res
69
if [ $grep_status -eq 0 ]; then
70
echo d.add ServerAddresses '*' \
71
`awk 'BEGIN { n="" } \
72
/^nameserver/ { n=n " " $2 } \
73
END { print n}' < $res` >> /tmp/$tmp
75
grep -q '^search' $res
77
if [ $grep_status -eq 0 ]; then
78
echo d.add SearchDomains '*' \
79
`sed 's/^search//' < $res` >> /tmp/$tmp
81
echo set State:/Network/Service/$serviceID/DNS >> /tmp/$tmp
82
echo quit >> /tmp/$tmp
84
/usr/sbin/scutil < /tmp/$tmp
89
$LOGGER "Can't find SystemConfiguration tools."
92
if [ $to_commit = force ]; then
93
$LOGGER "Can't find /var/run/resolv.conf.dhclient6"
99
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
102
if [ -f /etc/dhclient-exit-hooks ]; then
103
. /etc/dhclient-exit-hooks
105
# probably should do something with exit status of the local script
109
# Invoke the local dhcp client enter hooks, if they exist.
110
if [ -f /etc/dhclient-enter-hooks ]; then
112
. /etc/dhclient-enter-hooks
113
# allow the local script to abort processing of this state
114
# local script must set exit_status variable to nonzero.
115
if [ $exit_status -ne 0 ]; then
120
if [ x$reason = xMEDIUM ]; then
121
eval "ifconfig $interface $medium"
122
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
131
if [ x$reason = xPREINIT6 ]; then
132
# Ensure interface is up.
133
ifconfig ${interface} up
135
# XXX: Remove any stale addresses from aborted clients.
140
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ]; then
141
echo Prefix $reason old=${old_ip6_prefix} new=${new_ip6_prefix}
146
if [ x$reason = xBOUND6 ]; then
147
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ]; then
151
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
153
# Check for nameserver options.
159
if [ x$reason = xRENEW6 ] || [ x$reason = xREBIND6 ]; then
160
# Make sure nothing has moved around on us.
162
# Nameservers/domains/etc.
163
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
164
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ]; then
171
if [ x$reason = xDEPREF6 ]; then
172
if [ x${new_ip6_address} = x ]; then
176
ifconfig ${interface} inet6 ${new_ip6_address} deprecated
181
if [ x$reason = xEXPIRE6 -o x$reason = xRELEASE6 -o x$reason = xSTOP6 ]; then
182
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ]; then
186
ifconfig ${interface} inet6 ${old_ip6_address}/${old_ip6_prefixlen} -alias
191
if [ $to_commit = yes ]; then