net-loc revision ad559bec55fd74f310399483501e1fa231f65528
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater# CDDL HEADER START
f536382c59dd492a14667b753816d920f9981f1cTinderbox User# The contents of this file are subject to the terms of the
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# Common Development and Distribution License (the "License").
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# You may not use this file except in compliance with the License.
a7c412f37cc73d0332887a746e81220cbf09dd00Mark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews# See the License for the specific language governing permissions
8de3f14f1c300c3e1ed99084cc03485b42c92bf1Tinderbox User# and limitations under the License.
950d203b64f512b85fcc093ee1e9e3e531a1aea3Tinderbox User# When distributing Covered Code, include this CDDL HEADER in each
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews# If applicable, add the following below this CDDL HEADER, with the
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# fields enclosed by brackets "[]" replaced with your own identifying
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# information: Portions Copyright [yyyy] [name of copyright owner]
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# CDDL HEADER END
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# Path to directories
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# echoes DHCP controlled interfaces separated by commas
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# Don't parse the output of ifconfig(1M) because interfaces that haven't
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User# acquired a DHCP lease also have the DHCP flag set.
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews # 1. parse netstat(1M) output for v4 interfaces in BOUND
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # 2. make a space-separated list of interface names
015055b6e23f5c08f6a5b34726f90b62597e9e45Tinderbox User $2 ~ /BOUND/ { printf "%s ", $1 }
2ae159b376dac23870d8005563c585acf85a4b5aEvan Hunt $2 ~ /INFORMATION/ { printf "%s ", $1 }'
294e9d4c34462d29a3e766c88f452b46aeb3702fTinderbox User# get_dhcpinfo <code/identifier>
2ae159b376dac23870d8005563c585acf85a4b5aEvan Hunt# echoes the value received through each interface controlled by DHCP
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# 0 => property is set
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User# 1 => property is not set
ee11dfc481f2ef6a032a715454f6290961a722d2Tinderbox User # Get all interfaces with DHCP control, IFS is " "
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews if [ $? -eq 0 ]; then
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# set_smf_prop <fmri> <property name> <property value>
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews $SVCCFG -s $1 setprop $2 = astring: "$3" && return
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# refresh_svc <fmri>
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# Refreshes the service.
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User# restart_svc <fmri>
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews# Restarts the service.
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User# start_svc <fmri>
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# Starts the service. If the service is already enabled, restarts it. If
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont# it is not enabled, temporarily enables it.
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews# stop_svc <fmri>
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User# Temporarily disables the service.
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# copy_default <dir> <file>
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# Copies <dir>/<file>.dfl to <dir>/<file>
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User# enable_nonet
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# Enables the NoNet location. This function is called whenever an error is
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater# detected in the location currently being activated (missing property or the
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# location itself).
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User set_smf_prop $SMF_FMRI location/selected NoNet
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # Refresh nwam so that it re-does the condition checking
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater# do_dns <location>
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# Installs DNS information on /etc/resolv.conf for location
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User DNS_CONFIGSRC=`nwam_get_loc_prop $loc dns-nameservice-configsrc`
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User echo "missing 'dns-nameservice-configsrc' property for '$loc'"
ac2e2800b4ac9cbe4cb756d967f4583c611eb75eMark Andrews echo "Unrecognized DNS configsrc ${configsrc}; ignoring"
bac4435d473c9a0281507524f084480c34aa942aTinderbox User for (i = 1; i <= NF; i++) printf(" %s", $i); \
b02be031b9ff37b042adc8e68e36b8bbc1f672b7Tinderbox User # Finally, copy our working version to the real thing
ecbc7ebb243a1f8a5dc6f28185ffe9e61d3b2102Mark Andrews# do_nis <location>
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# Installs NIS information on /var/yp/binding/ for location
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont NIS_CONFIGSRC=`nwam_get_loc_prop $loc nis-nameservice-configsrc`
f525041ae26958385b697cf82a30f108577024b6Tinderbox User echo "missing 'nis-nameservice-configsrc' property for '$loc'"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews DEFAULT_DOMAIN=`nwam_get_loc_prop $loc default-domain`
ae454ec746d1d4db8d04e107d4d25ff13158c37fMark Andrews echo "Unrecognized NIS configsrc ${configsrc}; ignoring"
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # Place NIS settings in appropriate directory/file.
1bcc3273a80c256f11d9098a00ba2c041939e233Mark Andrews if [ ! -d "$NIS_BIND_PATH/$DEFAULT_DOMAIN" ]; then
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User 'FS="," { for (i = 1; i <= NF; i++) print $i }' \
ebdf202f2198158ab4d30f22c370a9c63760d071Tinderbox User# do_ldap <location>
caaff35375fba833f156f952aeca689e5bc7cddfFrancis Dupont# Installs LDAP information using ldapclient(1M) for location
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews LDAP_CONFIGSRC=`nwam_get_loc_prop $loc ldap-nameservice-configsrc`
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews echo "missing 'ldap-nameservice-configsrc' property for '$loc'"
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews DEFAULT_DOMAIN=`nwam_get_loc_prop $loc default-domain`
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews echo "Unrecognized LDAP configsrc ${configsrc}; ignoring"
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # Use ldapclient(1M) to initialize LDAP client settings.
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User if [ -n "$DEFAULT_DOMAIN" -o -n "$LDAP_SERVERS" ]; then
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # XXX need to check how to specify multiple LDAP servers.
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater $LDAPCLIENT init -a domainName=$DEFAULT_DOMAIN \
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews echo "LDAP configuration could not be set for '$loc'"
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# do_ns <location>
95c3a5e116c1da135f669c3f15398172fac6279dMark Andrews# Installs different nameservices for location
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # Disable nameservices temporarily while we reconfigure. Copy
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater # /etc/nsswitch.files to /etc/nsswitch.conf first so that only "files"
757ff043760e4743dda1a10e7d58349275934902Tinderbox User $CP -p /etc/nsswitch.files /etc/nsswitch.conf
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont # Remove /etc/defaultdomain and unset domainname(1M). If NIS
7f79131f9a8e804b93c57f3c679065cce878b726Automatic Updater # and/or LDAP is configured, they will create /etc/defaultdomain
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews NAMESERVICES=`nwam_get_loc_prop $loc nameservices`
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews echo "missing 'nameservices' property for location '$loc'"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington NAMESERVICES_CONFIG_FILE=`nwam_get_loc_prop \
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont echo "missing 'nameservices-config-file' property for '$loc'"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews $CP -p $NAMESERVICES_CONFIG_FILE /etc/nsswitch.conf
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User # no additional setup needed for files nameservice
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington echo "Unrecognized nameservices value ${ns}; ignoring"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # We explicitly restart here, as restart will only have an
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # effect if the service is already enabled. We don't want
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # to enable the service if it's currently disabled.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# do_sec <location>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# If config properties are set, update the SMF property and refresh the
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# service. If config properties are not set, delete the SMF property and
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# stop the service.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington ike_file=`nwam_get_loc_prop $loc ike-config-file`
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington pol_file=`nwam_get_loc_prop $loc ipsecpolicy-config-file`
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington ipf_file=`nwam_get_loc_prop $loc ipfilter-config-file`
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington ipf6_file=`nwam_get_loc_prop $loc ipfilter-v6-config-file`
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington ipnat_file=`nwam_get_loc_prop $loc ipnat-config-file`
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington ippool_file=`nwam_get_loc_prop $loc ippool-config-file`
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington set_smf_prop $IPSEC_IKE_FMRI config/config_file $ike_file
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington set_smf_prop $IPSEC_POLICY_FMRI config/config_file $pol_file
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater firewall_config_default/custom_policy_file $ipf_file
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater # change policy to "none", no need to clear custom_policy_file
b30ec46fec40a1b246f7965fbcd341fc6cfd1cc1Mark Andrews set_smf_prop $IPFILTER_FMRI firewall_config_default/policy \
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User # IPFilter has to be refreshed to make the changes effective.
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User # Don't set $refresh_ipf as it keeps IPFilter online rather
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User # than disabled. Refresh after IPFilter is disabled below.
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User set_smf_prop $IPFILTER_FMRI config/ipf6_config_file $ipf6_file
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews set_smf_prop $IPFILTER_FMRI config/ipnat_config_file $ipnat_file
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User set_smf_prop $IPFILTER_FMRI config/ippool_config_file \
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# update_nfs_file <new nfsv4 domain>
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # For non-commented-out lines that set NFSMAPID_DOMAIN:
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # if not previously added by nwam, comment out with a note
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User # For commented-out lines that set NFSMAPID_DOMAIN:
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont $0 ~ /^NFSMAPID_DOMAIN=/ {
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont if (index($0, "# Added by NWAM") == 0)
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont printf("#%s # Commented out by NWAM\n", $0);
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont $0 ~ /^#NFSMAPID_DOMAIN=/ {
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews if ($0 !~ /"# Commented out by NWAM"/)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington printf("%s\n", $0);
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington $1 !~ /NFSMAPID_DOMAIN=/ {
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington printf("%s\n", $0);
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington echo "NFSMAPID_DOMAIN=$domain # Added by NWAM" >> $file.$$
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # Finally, copy our working version to the real thing
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# do_nfsv4 <location>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Updates NFSv4 domain for location
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington nfsv4domain=`nwam_get_loc_prop $loc nfsv4-domain`
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews if [ $? -eq 0 ]; then
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# activate_loc <location>
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# Activates the given location
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Script entry point
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Arguments to net-loc are
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# method ('start' or 'refresh')
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# If nwam is not enabled, do nothing and return OK.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonservice_is_enabled $NWAM_FMRI || exit $SMF_EXIT_OK
409ba95e573b40cf36acf97dd62ee7e9c7775851Tinderbox User# In a shared-IP zone we need this service to be up, but all of the work
7adcb4de92bf4383a4c5624c4ed256736d02bc6dMark Andrews# it tries to do is irrelevant (and will actually lead to the service
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# failing if we try to do it), so just bail out.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# In the global zone and exclusive-IP zones we proceed.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # We need to create the default (NoNet and Automatic)
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # locations, if they don't already exist. So: first check
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User # for the existence of each, and then run the appropriate
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # nwamcfg script(s) as needed. Restart nwamd if a location is
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # created, as it needs to read it in.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington $NWAMCFG list loc Automatic >/dev/null 2>&1
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $NWAMCFG -f /etc/nwam/loc/create_loc_nonet
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont # location selection/activation happens below
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont # location selection/activation happens below
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont echo "Usage: $0 start|refresh"
7adcb4de92bf4383a4c5624c4ed256736d02bc6dMark Andrews# If the Legacy location doesn't exist and the file to create the Legacy
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# location exists, create the Legacy location. Make a copy of it as the user's
7adcb4de92bf4383a4c5624c4ed256736d02bc6dMark Andrews# intentions before upgrade. Then activate the User location if nis is
7adcb4de92bf4383a4c5624c4ed256736d02bc6dMark Andrews# involved. Because NIS affects more parts of the system (e.g. automounts) we
7adcb4de92bf4383a4c5624c4ed256736d02bc6dMark Andrews# are not willing to make NIS part of the Automatic location (i.e. enable it
7adcb4de92bf4383a4c5624c4ed256736d02bc6dMark Andrews# automatically based on external input) as we do with DHCP-driven DNS.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonif [ $? -eq 1 -a -f "$SCRIPT_PATH/create_loc_legacy" ]; then
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # We built the script in and pointing to /etc/svc/volatile because we
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # may not have a writable filesystem in net-nwam. So here we move the
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # components and rewrite the script to point at the writable filesystem.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington $CP -r $SCRIPT_PATH/Legacy $LEGACY_LOC_PATH
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington $MV $SCRIPT_PATH/create_loc_legacy $SCRIPT_PATH/vcreate_loc_legacy
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington $SED -e's,/etc/svc/volatile/nwam/Legacy,/etc/nwam/loc/Legacy,' \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington $SCRIPT_PATH/vcreate_loc_legacy >$SCRIPT_PATH/create_loc_legacy
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews loc_ver=`$SVCPROP -c -p location_upgrade/version $LOCATION_FMRI \
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User # We are rewriting configuration variables from the Legacy
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # location to the User location. Use variable ULP to keep REs
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont # within a line.
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User -e's,activation-mode=system,activation-mode=manual,' \
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews -e"s,\(ipfilter-config-file=\).*/\(.*\),\1$ULP/\2," \
757ff043760e4743dda1a10e7d58349275934902Tinderbox User -e"s,\(ipfilter-v6-config-file=\).*/\(.*\),\1$ULP/\2," \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews -e"s,\(ipnat-config-file=\).*/\(.*\),\1$ULP/\2," \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews -e"s,\(ippool-config-file=\).*/\(.*\),\1$ULP/\2," \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews -e"s,\(ike-config-file=\).*/\(.*\),\1$ULP/\2," \
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews -e"s,\(ipsecpolicy-config-file=\).*/\(.*\),\1$ULP/\2," \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews -e's,/etc/nwam/loc/User/allow,/allow,' \
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont -e's,/etc/nwam/loc/User/deny,/deny,' \
646fed0d28be4387e3e32fb0f5732a1f58b572baTinderbox User # We are creating the User location here. The User location
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # is an appromixation of the machine configuration when the
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # user change or upgraded to this version of NWAM. First
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # we make sure there isn't an existing User location or any
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # existing User location data. We then copy all the data
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # from the Legacy location and create a location pointing at
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # that data. Lastly we create a version property to note
280a8a0544b4aeb52414d20e8c6e6c5b1108562eTinderbox User # that we have done this.
cc5a9ce75af9870f2cb9e2bf00548c2f7e6398d6Automatic Updater # The User location is activated if 'nis' is in a non comment
ec8755f605d7dcb2de1076040e77bc2d7ec33b4aTinderbox User $GREP -v "^#" $USER_LOC_PATH/nsswitch.conf |\
bac4435d473c9a0281507524f084480c34aa942aTinderbox User $SED -e 's/[^:]*://' | $GREP nis >/dev/null 2>&1
532d27b39244fadfcf8d8b4593f4c65434c9c664Automatic Updater $SVCCFG -s $SMF_FMRI addpg location_upgrade application \
532d27b39244fadfcf8d8b4593f4c65434c9c664Automatic Updater $SVCCFG -s $SMF_FMRI setprop location_upgrade/version = \
ae454ec746d1d4db8d04e107d4d25ff13158c37fMark Andrews# Activate a location. If we've just finished upgrading, and
ae454ec746d1d4db8d04e107d4d25ff13158c37fMark Andrews# the User location should be activated, do that (and use nwamadm
10702d681eb650391bcaa0e2704aa3cf2dbf0e98Mark Andrews# to do so, so the enabled property gets set and nwamd knows this
10702d681eb650391bcaa0e2704aa3cf2dbf0e98Mark Andrews# selection has been made). Otherwise, if our location/selected
10702d681eb650391bcaa0e2704aa3cf2dbf0e98Mark Andrews# property has a value, we activate that location; else we activate
10702d681eb650391bcaa0e2704aa3cf2dbf0e98Mark Andrews# the NoNet location as a default value.
10702d681eb650391bcaa0e2704aa3cf2dbf0e98Mark Andrews sel_loc=`$SVCPROP -c -p location/selected $SMF_FMRI 2>/dev/null`
93089a352d6903b0d7845a039de4ec2df9a0e35aTinderbox User # location hasn't been selected; default to NoNet
e8c17c74535be290abaaa160a434ed80bf0ad2feMark Andrews # check if the selected location exists
9c446b72069d0ab9f710502f4d7048e50875fccbAutomatic Updater echo "location '$sel_loc' doesn't exist"
9e898948ed76bf5f175bf178866c90c449843c3eTinderbox User # activate selected location