net-loc revision dd51520e127b452179a2ce4ea3bd8dee949f9afe
2N/A# The contents of this file are subject to the terms of the 2N/A# Common Development and Distribution License (the "License"). 2N/A# You may not use this file except in compliance with the License. 2N/A# See the License for the specific language governing permissions 2N/A# and limitations under the License. 2N/A# When distributing Covered Code, include this CDDL HEADER in each 2N/A# If applicable, add the following below this CDDL HEADER, with the 2N/A# fields enclosed by brackets "[]" replaced with your own identifying 2N/A# information: Portions Copyright [yyyy] [name of copyright owner] 2N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2N/A# Path to directories 2N/A# echoes DHCP controlled interfaces separated by commas 2N/A# Don't parse the output of ifconfig(1M) because interfaces that haven't 2N/A# acquired a DHCP lease also have the DHCP flag set. 2N/A # 1. parse netstat(1M) output for v4 interfaces in BOUND 2N/A # or INFORMATION state 2N/A # 2. make a space-separated list of interface names 2N/A $2 ~ /BOUND/ { printf "%s ", $1 } 2N/A $2 ~ /INFORMATION/ { printf "%s ", $1 }' 2N/A# echoes the value received through each interface controlled by DHCP; 2N/A# multiple values are echoed as a space-separated list 2N/A# 0 => property is set 2N/A# 1 => property is not set 2N/A # Get all interfaces with DHCP control, IFS is " " 2N/A# set_smf_prop <fmri> <property name> <property value> 2N/A# Refreshes the service. 2N/A# Restarts the service. 2N/A# Starts the service. If the service is already enabled, restarts it. If 2N/A# it is not enabled, temporarily enables it. 2N/A# Temporarily disables the service. 2N/A# copy_default <dir> <file> 2N/A# Copies <dir>/<file>.dfl to <dir>/<file> 2N/A# Returns 0 on success, 1 on failure 2N/A # Write out to temporary file first 2N/A echo "missing 'dns-nameservice-configsrc' property for '$loc'" 2N/A echo "DNS nameserver not set for '$loc'" 2N/A # No DNS search info for IPv4 2N/A echo "Unrecognized DNS configsrc ${configsrc}; ignoring" 2N/A # Write DNS settings 2N/A '{ for (i = 1; i <= NF; i++) \ 2N/A '{ printf("search"); \ 2N/A for (i = 1; i <= NF; i++) printf(" %s", $i); \ 2N/A '{ for (i = 1; i <= NF; i++) \ 2N/A # Finally, copy our working version to the real thing 2N/A# Returns 0 on success, 1 on failure 2N/A echo "missing 'nis-nameservice-configsrc' property for '$loc'" 2N/A # user-specified default-domain always wins 2N/A echo "'domainname' not set for '$loc'" 2N/A # Use only the first name 2N/A echo "Unrecognized NIS configsrc ${configsrc}; ignoring" 2N/A '{ for (i = 1; i <= NF; i++) print $i }' \ 2N/A# Installs LDAP information using ldapclient(1M) for location 2N/A# Returns 0 on success, 1 on failure 2N/A echo "missing 'ldap-nameservice-configsrc' property for '$loc'" 2N/A echo "LDAP configuration could not be set "\ 2N/A echo "Invalid LDAP configsrc ${configsrc}; ignoring" 2N/A # Use ldapclient(1M) to initialize LDAP client settings. 2N/A# Installs different nameservices for location 2N/A# Returns 0 on success, 1 on failure 2N/A # Disable nameservices temporarily while we reconfigure. Copy 2N/A # and set the domainname(1M). 2N/A echo "missing 'nameservices' property for location '$loc'" 2N/A echo "missing 'nameservices-config-file' property for '$loc'" 2N/A # no additional setup needed for files nameservice 2N/A echo "Unrecognized nameservices value ${ns}; ignoring" 2N/A # Restart other related services 2N/A # We explicitly restart here, as restart will only have an 2N/A # effect if the service is already enabled. We don't want 2N/A # to enable the service if it's currently disabled. 2N/A# If config properties are set, update the SMF property and refresh the 2N/A# service. If config properties are not set, delete the SMF property and 2N/A# Returns 0 on success, 1 on failure # custom policy with policy file # change policy to "none", no need to clear custom_policy_file # IPFilter has to be refreshed to make the changes effective. # Don't set $refresh_ipf as it keeps IPFilter online rather # than disabled. Refresh after IPFilter is disabled below. # Updates NFSv4 domain for location in SMF # Returns 0 on success, 1 on failure # activate_loc <location> # Activates the given location # Returns 0 on success, 1 on failure # if we fail to complete any part of the config, # stop activation work and report failure. # Arguments to net-loc are # method ('start' or 'refresh') # If nwam is not enabled, do nothing and return OK. # 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. # We need to create the default (NoNet and Automatic) # locations, if they don't already exist. So: first check # for the existence of each, and then run the appropriate # nwamcfg script(s) as needed. Restart nwamd if a location is # created, as it needs to read it in. echo "Usage: $0 start|refresh" # If the Legacy location doesn't exist and the file to create the Legacy # location exists, create the Legacy location. Make a copy of it as the user's # intentions before upgrade. Then activate the User location if nis is # involved. Because NIS affects more parts of the system (e.g. automounts) we # are not willing to make NIS part of the Automatic location (i.e. enable it # automatically based on external input) as we do with DHCP-driven DNS. # may not have a writable filesystem in net-nwam. So here we move the # components and rewrite the script to point at the writable filesystem. # We are rewriting configuration variables from the Legacy # location to the User location. Use variable ULP to keep REs $SED -e
's,Legacy,User,' \
-e
's,activation-mode=system,activation-mode=manual,' \
-e
"s,\(ipfilter-config-file=\).*/\(.*\),\1$ULP/\2," \
-e
"s,\(ipfilter-v6-config-file=\).*/\(.*\),\1$ULP/\2," \
-e
"s,\(ipnat-config-file=\).*/\(.*\),\1$ULP/\2," \
-e
"s,\(ippool-config-file=\).*/\(.*\),\1$ULP/\2," \
-e
"s,\(ike-config-file=\).*/\(.*\),\1$ULP/\2," \
-e
"s,\(ipsecpolicy-config-file=\).*/\(.*\),\1$ULP/\2," \
# We are creating the User location here. The User location # is an appromixation of the machine configuration when the # user change or upgraded to this version of NWAM. First # we make sure there isn't an existing User location or any # existing User location data. We then copy all the data # from the Legacy location and create a location pointing at # that data. Lastly we create a version property to note # that we have done this. # The User location is activated if 'nis' is in a non comment # Activate a location. If we've just finished upgrading, and # the User location should be activated, do that (and use nwamadm # to do so, so the enabled property gets set and nwamd knows this # property has a value, we activate that location; else we activate # the NoNet location as a default value. # location hasn't been selected; default to NoNet # If the selected location does not exist, or if we fail # to activate it completely, we fall back to the NoNet # location. Also poke nwamd, so it will check conditions echo "location '$sel_loc' doesn't exist" # activate selected location