#!/usr/sbin/sh # # Copyright (c) 1991, 2012, Oracle and/or its affiliates. All rights reserved. # # # This is third phase of TCP/IP startup/configuration. This script # runs after the NIS startup script. We run things here that may # depend on NIS maps. # . /lib/svc/share/smf_include.sh . /lib/svc/share/net_include.sh case "$1" in 'start') # # In a shared-IP zone we need this service to be up, but all of the # work it tries to do is irrelevant (and will actually lead to the # service failing if we try to do it), so just bail out. # In the global zone and exclusive-IP zones we proceed. # smf_configure_ip || exit $SMF_EXIT_OK # # If nwam (i.e., reactive NCP) is enabled, the network/location # service will handle the tasks performed by this service, so just # bail out. For fixed NCP, we proceed. # ncp_is_fixed `get_active_ncp` || exit $SMF_EXIT_OK ;; # fall through -- rest of script is the initialization code 'stop') exit $SMF_EXIT_OK ;; *) echo "Usage: $0 { start | stop }" exit 1 ;; esac # If boot variables are not set, set variables we use [ -z "$_INIT_UTS_NODENAME" ] && _INIT_UTS_NODENAME=`/usr/bin/uname -n` # # update_resolv() # # Update the "nameserver" and "domain" entries for /etc/resolv.conf with new # ones given out by the DHCP server. # # The first argument is the dns servers string and should always exist, the # second is the optional dns domain. # update_resolv () { dnsservers=$1 dnsdomain=$2 $SVCCFG -s $DNS_CLIENT_FMRI \ setprop config/nameserver = net_address: "( $dnsservers )" if [ -n "$dnsdomain" ]; then $SVCCFG -s $DNS_CLIENT_FMRI \ setprop config/domain = astring: "$dnsdomain" else $SVCCFG -s $DNS_CLIENT_FMRI delprop config/domain 2>/dev/null fi $SVCADM refresh $DNS_CLIENT_FMRI # dns/client is disabled in the manifest $SVCADM enable -t $DNS_CLIENT_FMRI } # # update_nsswitch() # # Append "dns" to the "hosts" entry of /etc/nsswitch.conf if it is not already # there. # update_nsswitch () { $SVCPROP -cp config/host $NS_SWITCH_FMRI 2>/dev/null | read host echo $host | $GREP "dns" >/dev/null if [ $? -eq 1 ]; then # if "hosts" entry does not exist at all, have "files" too if [ -z "$host" ]; then host="files dns" else host="$host dns" fi $SVCCFG -s $NS_SWITCH_FMRI setprop \ config/host = astring: \"$host\" $SVCADM refresh $NS_SWITCH_FMRI fi } # # If our network configuration strategy is DHCP, check for DNS # configuration parameters obtained from the DHCP server. # # Script execution starts here. # smf_netstrategy if [ "$_INIT_NET_STRATEGY" = "dhcp" ]; then dnsservers=`/usr/sbin/dhcpinfo DNSserv` dnsdomain=`/usr/sbin/dhcpinfo DNSdmain` if [ -n "$dnsservers" ]; then # add settings retrieved from DHCP server to /etc/resolv.conf update_resolv "$dnsservers" "$dnsdomain" # add "dns" to /etc/nsswitch.conf, if it isn't already there update_nsswitch fi fi exit $SMF_EXIT_OK