5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
27 # Install DNS client service
30 .
/lib
/svc
/share
/smf_include.sh
31 .
/lib
/svc
/share
/net_include.sh
33 SVCCFG
=/usr
/sbin
/svccfg
34 SVCPROP
=/usr
/bin
/svcprop
35 SVCADM
=/usr
/sbin
/svcadm
37 DNS_NWAM_FMRI
="svc:/network/physical:nwam"
38 DNS_INSTALL_FMRI
=$SMF_FMRI
40 DNS_INSTALL_PG
="install_props"
42 DNS_UNDEFINED_STRING_PROP
="\"\""
46 unset dns_install_domain dns_install_servers dns_install_search
48 dns_process_install_pg
()
51 dns_install_servers
=""
56 # Retrieve the name server property values.
58 prop
=`$SVCPROP -p $DNS_INSTALL_PG/nameserver $DNS_INSTALL_FMRI`
59 if [ $?
-eq 0 -a "$prop" != "$NET_INADDR_ANY" ]; then
60 dns_install_servers
=$prop
65 # Retrieve the name service domain.
67 prop
=`$SVCPROP -p $DNS_INSTALL_PG/domain $DNS_INSTALL_FMRI`
68 if [ $?
-eq 0 -a "$prop" != "$DNS_UNDEFINED_STRING_PROP" ]; then
69 dns_install_domain
=$prop
74 # Retrieve the search list.
76 prop
=`$SVCPROP -p $DNS_INSTALL_PG/search $DNS_INSTALL_FMRI`
77 if [ $?
-eq 0 -a "$prop" != "$DNS_UNDEFINED_STRING_PROP" ]; then
78 dns_install_search
=$prop
82 [ $config -ne 0 ] ||
return $SMF_EXIT_OK
85 # Create the resolv.conf file.
87 /usr
/bin
/touch /etc
/resolv.conf.$$
89 net_record_err
"Error creating \"/etc/resolv.conf.$$\"" $?
90 return $SMF_EXIT_ERR_FATAL
93 for j
in $dns_install_servers
95 server
=`echo $j | /usr/bin/sed s/\"//g`
96 echo "nameserver $server" >>/etc
/resolv.conf.$$
99 if [ "$dns_install_domain" != "" ]; then
100 echo "domain $dns_install_domain" >>/etc
/resolv.conf.$$
103 if [ "$dns_install_search" != "" ]; then
105 for j
in $dns_install_search
107 domain
=`echo $j | /usr/bin/sed s/\"//g`
110 echo $list >>/etc
/resolv.conf.$$
113 /usr
/bin
/mv /etc
/resolv.conf.$$
/etc
/resolv.conf
114 if [ $?
-ne 0 ]; then
116 msg
="Error moving /etc/resolv.conf.$$ to \"/etc/resolv.conf\""
117 net_record_err
"$msg" $err
118 return $SMF_EXIT_ERR_FATAL
121 /usr
/bin
/chmod 644 /etc
/resolv.conf
122 if [ $?
-ne 0 ]; then
124 msg
="Error setting permissions on \"/etc/resolv.conf\""
125 net_record_err
"$msg" $err
126 return $SMF_EXIT_ERR_FATAL
130 # Create the nsswitch.conf file
132 /usr
/bin
/cp -f /etc
/nsswitch.dns
/etc
/nsswitch.conf
133 if [ $?
-ne 0 ]; then
135 msg
="Error copying /etc/nsswitch.dns to \"/etc/nsswitch.conf\""
136 net_record_err
"$msg" $err
137 return $SMF_EXIT_ERR_FATAL
140 /usr
/bin
/chmod 644 /etc
/nsswitch.conf
141 if [ $?
-ne 0 ]; then
143 msg
="Error setting permissions on \"/etc/nsswitch.conf\""
144 net_record_err
"$msg" $err
145 return $SMF_EXIT_ERR_FATAL
151 dns_process_install
()
153 vout
=`$SVCCFG -s $DNS_INSTALL_FMRI validate 2>&1`
154 if [ "$vout" != "" ]; then
155 msg
="Validation errors in $DNS_INSTALL_FMRI:\n$vout"
156 net_record_err
"$msg" 0
157 return $SMF_EXIT_ERR_CONFIG
163 pg
=`$SVCPROP -p $DNS_INSTALL_PG $DNS_INSTALL_FMRI`
164 if [ $?
-eq 0 ]; then
165 if service_is_enabled
$DNS_NWAM_FMRI; then
166 echo "NWAM enabled. Install static" \
167 "DNS configuration ignored." | smf_console
168 errs
=`expr $errs + 1`
169 ecode
=$SMF_EXIT_ERR_CONFIG
171 dns_process_install_pg
172 if [ $?
-ne $SMF_EXIT_OK ]; then
174 errs
=`expr $errs + 1`
180 $SVCCFG -s $DNS_INSTALL_FMRI delpg
$DNS_INSTALL_PG
181 $SVCCFG -s $DNS_INSTALL_FMRI refresh
184 if [ $dns_install_debug -eq 1 ]; then
185 if [ $errs -ne 0 ]; then
186 echo "$errs errors encountered" \
187 "configuring DNS on behalf of install"
190 if [ $cntf -ne 0 ]; then
191 echo "DNS configured on behalf of install"
199 # Script execution starts here.
201 dns_process_install ||
exit $?
203 $SVCADM disable
$DNS_INSTALL_FMRI