net-loc revision 8f605d57121d83ba412586f242ee8eefd2e08a0b
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# CDDL HEADER START
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# The contents of this file are subject to the terms of the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Common Development and Distribution License (the "License").
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# You may not use this file except in compliance with the License.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# or http://www.opensolaris.org/os/licensing.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# See the License for the specific language governing permissions
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# and limitations under the License.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# When distributing Covered Code, include this CDDL HEADER in each
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# If applicable, add the following below this CDDL HEADER, with the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# fields enclosed by brackets "[]" replaced with your own identifying
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# information: Portions Copyright [yyyy] [name of copyright owner]
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# CDDL HEADER END
4a44f0a129f99893a7aef6325037c5e1fa702a0fAnurag S. Maskey# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. MaskeyIPSEC_POLICY_FMRI="svc:/network/ipsec/policy"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. MaskeyIPFILTER_FMRI="svc:/network/ipfilter:default"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. MaskeyLOCATION_FMRI="svc:/network/location:default"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Path to directories
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# echoes DHCP controlled interfaces separated by commas
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Don't parse the output of ifconfig(1M) because interfaces that haven't
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# acquired a DHCP lease also have the DHCP flag set.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # 1. parse netstat(1M) output for v4 interfaces in BOUND
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # 2. make a space-separated list of interface names
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $2 ~ /BOUND/ { printf "%s ", $1 }
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $2 ~ /INFORMATION/ { printf "%s ", $1 }'
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# get_dhcpinfo <code/identifier>
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# echoes the value received through each interface controlled by DHCP;
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# multiple values are echoed as a space-separated list
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# 0 => property is set
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# 1 => property is not set
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Get all interfaces with DHCP control, IFS is " "
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if [ $? -eq 0 ]; then
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# set_smf_prop <fmri> <property name> <property value>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $SVCCFG -s $1 setprop $2 = astring: "$3" && return
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# refresh_svc <fmri>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Refreshes the service.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# restart_svc <fmri>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Restarts the service.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# start_svc <fmri>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Starts the service. If the service is already enabled, restarts it. If
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# it is not enabled, temporarily enables it.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# stop_svc <fmri>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Temporarily disables the service.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# copy_default <dir> <file>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Copies <dir>/<file>.dfl to <dir>/<file>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# do_dns <location>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Installs DNS information on /etc/resolv.conf for location
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# Returns 0 on success, 1 on failure
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld DNS_CONFIGSRC=`nwam_get_loc_list_prop $loc dns-nameservice-configsrc`
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey echo "missing 'dns-nameservice-configsrc' property for '$loc'"
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld DNS_SERVERS=`nwam_get_loc_list_prop $loc \
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld echo "DNS nameserver not set for '$loc'"
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld DNS_SEARCH=`nwam_get_loc_list_prop $loc \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey echo "Unrecognized DNS configsrc ${configsrc}; ignoring"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey for (i = 1; i <= NF; i++) printf(" %s", $i); \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Finally, copy our working version to the real thing
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# do_nis <location>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Installs NIS information on /var/yp/binding/ for location
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# Returns 0 on success, 1 on failure
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld NIS_CONFIGSRC=`nwam_get_loc_list_prop $loc nis-nameservice-configsrc`
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey echo "missing 'nis-nameservice-configsrc' property for '$loc'"
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld NIS_SERVERS=`nwam_get_loc_list_prop $loc \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey DEFAULT_DOMAIN=`nwam_get_loc_prop $loc default-domain`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # user-specified default-domain always wins
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld echo "'domainname' not set for '$loc'"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey echo "Unrecognized NIS configsrc ${configsrc}; ignoring"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Place NIS settings in appropriate directory/file.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if [ ! -d "$NIS_BIND_PATH/$DEFAULT_DOMAIN" ]; then
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld '{ for (i = 1; i <= NF; i++) print $i }' \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# do_ldap <location>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Installs LDAP information using ldapclient(1M) for location
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# Returns 0 on success, 1 on failure
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld LDAP_CONFIGSRC=`nwam_get_loc_list_prop $loc ldap-nameservice-configsrc`
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey echo "missing 'ldap-nameservice-configsrc' property for '$loc'"
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld LDAP_SERVERS=`nwam_get_loc_list_prop $loc \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey DEFAULT_DOMAIN=`nwam_get_loc_prop $loc default-domain`
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld if [ -z $LDAP_SERVERS -o -z $DEFAULT_DOMAIN ]; then
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld echo "LDAP configuration could not be set "\
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld echo "Invalid LDAP configsrc ${configsrc}; ignoring"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Use ldapclient(1M) to initialize LDAP client settings.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if [ -n "$DEFAULT_DOMAIN" -o -n "$LDAP_SERVERS" ]; then
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $LDAPCLIENT init -a domainName=$DEFAULT_DOMAIN \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# do_ns <location>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Installs different nameservices for location
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# Returns 0 on success, 1 on failure
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Disable nameservices temporarily while we reconfigure. Copy
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # /etc/nsswitch.files to /etc/nsswitch.conf first so that only "files"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $CP -p /etc/nsswitch.files /etc/nsswitch.conf
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Remove /etc/defaultdomain and unset domainname(1M). If NIS
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # and/or LDAP is configured, they will create /etc/defaultdomain
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld NAMESERVICES=`nwam_get_loc_list_prop $loc nameservices`
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey echo "missing 'nameservices' property for location '$loc'"
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey NAMESERVICES_CONFIG_FILE=`nwam_get_loc_prop \
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey if [ -z "$NAMESERVICES_CONFIG_FILE" ]; then
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey echo "missing 'nameservices-config-file' property for '$loc'"
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey $CP -p $NAMESERVICES_CONFIG_FILE /etc/nsswitch.conf
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # no additional setup needed for files nameservice
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey echo "Unrecognized nameservices value ${ns}; ignoring"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # We explicitly restart here, as restart will only have an
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # effect if the service is already enabled. We don't want
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # to enable the service if it's currently disabled.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# do_sec <location>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# If config properties are set, update the SMF property and refresh the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# service. If config properties are not set, delete the SMF property and
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# stop the service.
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# Returns 0 on success, 1 on failure
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey ike_file=`nwam_get_loc_prop $loc ike-config-file`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey pol_file=`nwam_get_loc_prop $loc ipsecpolicy-config-file`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey ipf_file=`nwam_get_loc_prop $loc ipfilter-config-file`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey ipf6_file=`nwam_get_loc_prop $loc ipfilter-v6-config-file`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey ipnat_file=`nwam_get_loc_prop $loc ipnat-config-file`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey ippool_file=`nwam_get_loc_prop $loc ippool-config-file`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey set_smf_prop $IPSEC_IKE_FMRI config/config_file $ike_file
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey set_smf_prop $IPSEC_POLICY_FMRI config/config_file $pol_file
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey firewall_config_default/custom_policy_file $ipf_file
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # change policy to "none", no need to clear custom_policy_file
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey set_smf_prop $IPFILTER_FMRI firewall_config_default/policy \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # IPFilter has to be refreshed to make the changes effective.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Don't set $refresh_ipf as it keeps IPFilter online rather
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # than disabled. Refresh after IPFilter is disabled below.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey set_smf_prop $IPFILTER_FMRI config/ipf6_config_file $ipf6_file
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey set_smf_prop $IPFILTER_FMRI config/ipnat_config_file $ipnat_file
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey set_smf_prop $IPFILTER_FMRI config/ippool_config_file \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# update_nfs_file <new nfsv4 domain>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # For non-commented-out lines that set NFSMAPID_DOMAIN:
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # if not previously added by nwam, comment out with a note
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # For commented-out lines that set NFSMAPID_DOMAIN:
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # if not commented out by NWAM, leave as-is
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $0 ~ /^NFSMAPID_DOMAIN=/ {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if (index($0, "# Added by NWAM") == 0)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey printf("#%s # Commented out by NWAM\n", $0);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $0 ~ /^#NFSMAPID_DOMAIN=/ {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if ($0 !~ /"# Commented out by NWAM"/)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey printf("%s\n", $0);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $1 !~ /NFSMAPID_DOMAIN=/ {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey printf("%s\n", $0);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey echo "NFSMAPID_DOMAIN=$domain # Added by NWAM" >> $file.$$
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # Finally, copy our working version to the real thing
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# do_nfsv4 <location>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Updates NFSv4 domain for location
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# Returns 0 on success, 1 on failure
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey nfsv4domain=`nwam_get_loc_prop $loc nfsv4-domain`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if [ $? -eq 0 ]; then
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# activate_loc <location>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Activates the given location
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld# Returns 0 on success, 1 on failure
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld # if we fail to complete any part of the config,
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld # stop activation work and report failure.
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld do_sec $loc && do_ns $loc && do_nfsv4 $loc && return 0
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Script entry point
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Arguments to net-loc are
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# method ('start' or 'refresh')
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# If nwam is not enabled, do nothing and return OK.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyservice_is_enabled $NWAM_FMRI || exit $SMF_EXIT_OK
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# In a shared-IP zone we need this service to be up, but all of the work
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# it tries to do is irrelevant (and will actually lead to the service
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# failing if we try to do it), so just bail out.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# In the global zone and exclusive-IP zones we proceed.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # We need to create the default (NoNet and Automatic)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # locations, if they don't already exist. So: first check
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # for the existence of each, and then run the appropriate
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # nwamcfg script(s) as needed. Restart nwamd if a location is
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # created, as it needs to read it in.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $NWAMCFG list loc Automatic >/dev/null 2>&1
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # location selection/activation happens below
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # location selection/activation happens below
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey echo "Usage: $0 start|refresh"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# If the Legacy location doesn't exist and the file to create the Legacy
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# location exists, create the Legacy location. Make a copy of it as the user's
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# intentions before upgrade. Then activate the User location if nis is
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# involved. Because NIS affects more parts of the system (e.g. automounts) we
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# are not willing to make NIS part of the Automatic location (i.e. enable it
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# automatically based on external input) as we do with DHCP-driven DNS.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyif [ $? -eq 1 -a -f "$SCRIPT_PATH/create_loc_legacy" ]; then
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # We built the script in and pointing to /etc/svc/volatile because we
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # may not have a writable filesystem in net-nwam. So here we move the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # components and rewrite the script to point at the writable filesystem.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $CP -r $SCRIPT_PATH/Legacy $LEGACY_LOC_PATH
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $MV $SCRIPT_PATH/create_loc_legacy $SCRIPT_PATH/vcreate_loc_legacy
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $SED -e's,/etc/svc/volatile/nwam/Legacy,/etc/nwam/loc/Legacy,' \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $SCRIPT_PATH/vcreate_loc_legacy >$SCRIPT_PATH/create_loc_legacy
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey loc_ver=`$SVCPROP -c -p location_upgrade/version $LOCATION_FMRI \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # We are rewriting configuration variables from the Legacy
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # location to the User location. Use variable ULP to keep REs
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # within a line.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e's,activation-mode=system,activation-mode=manual,' \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e"s,\(ipfilter-config-file=\).*/\(.*\),\1$ULP/\2," \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e"s,\(ipfilter-v6-config-file=\).*/\(.*\),\1$ULP/\2," \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e"s,\(ipnat-config-file=\).*/\(.*\),\1$ULP/\2," \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e"s,\(ippool-config-file=\).*/\(.*\),\1$ULP/\2," \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e"s,\(ike-config-file=\).*/\(.*\),\1$ULP/\2," \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e"s,\(ipsecpolicy-config-file=\).*/\(.*\),\1$ULP/\2," \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $SED -e's,/etc/nwam/loc/User/none,/none,' \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e's,/etc/nwam/loc/User/allow,/allow,' \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey -e's,/etc/nwam/loc/User/deny,/deny,' \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # We are creating the User location here. The User location
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # is an appromixation of the machine configuration when the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # user change or upgraded to this version of NWAM. First
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # we make sure there isn't an existing User location or any
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # existing User location data. We then copy all the data
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # from the Legacy location and create a location pointing at
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # that data. Lastly we create a version property to note
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # that we have done this.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # The User location is activated if 'nis' is in a non comment
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $GREP -v "^#" $USER_LOC_PATH/nsswitch.conf |\
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $SED -e 's/[^:]*://' | $GREP nis >/dev/null 2>&1
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $SVCCFG -s $SMF_FMRI addpg location_upgrade application \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey $SVCCFG -s $SMF_FMRI setprop location_upgrade/version = \
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# Activate a location. If we've just finished upgrading, and
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# the User location should be activated, do that (and use nwamadm
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# to do so, so the enabled property gets set and nwamd knows this
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# selection has been made). Otherwise, if our location/selected
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# property has a value, we activate that location; else we activate
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey# the NoNet location as a default value.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey sel_loc=`$SVCPROP -c -p location/selected $SMF_FMRI 2>/dev/null`
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey # location hasn't been selected; default to NoNet
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld # If the selected location does not exist, or if we fail
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld # to activate it completely, we fall back to the NoNet
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld # location. Also poke nwamd, so it will check conditions
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld # for a better choice.
ad559bec55fd74f310399483501e1fa231f65528Anurag S. Maskey echo "location '$sel_loc' doesn't exist"
4a44f0a129f99893a7aef6325037c5e1fa702a0fAnurag S. Maskey # activate selected location
03e9aa6d0661fbdf89669b14e801767d7e504fe8Renee Danson Sommerfeld echo "failed to activate '$sel_loc'"