net-loc revision 6ba597c56d749c61b4f783157f63196d7b2445f0
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem# CDDL HEADER START
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# The contents of this file are subject to the terms of the
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# Common Development and Distribution License (the "License").
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# You may not use this file except in compliance with the License.
4da61833a1cbbca94094f9653fd970582b97a72etrawick# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4da61833a1cbbca94094f9653fd970582b97a72etrawick# See the License for the specific language governing permissions
4da61833a1cbbca94094f9653fd970582b97a72etrawick# and limitations under the License.
4789804be088bcd86ae637a29cdb7fda25169521jailletc# When distributing Covered Code, include this CDDL HEADER in each
4789804be088bcd86ae637a29cdb7fda25169521jailletc# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4789804be088bcd86ae637a29cdb7fda25169521jailletc# If applicable, add the following below this CDDL HEADER, with the
e50c3026198fd496f183cda4c32a202925476778covener# fields enclosed by brackets "[]" replaced with your own identifying
e50c3026198fd496f183cda4c32a202925476778covener# information: Portions Copyright [yyyy] [name of copyright owner]
5b88c8507d5ef6d0c4cfbc78230294968175b638minfrin# CDDL HEADER END
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic# Use is subject to license terms.
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavic# FMRI consts
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener# Path to directories
5d1ba75b8794925e67591c209085a49279791de9covener# echoes DHCP controlled interfaces separated by commas
5d1ba75b8794925e67591c209085a49279791de9covener# Don't parse the output of ifconfig(1M) because interfaces that haven't
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrand# acquired a DHCP lease also have the DHCP flag set.
caad2986f81ab263f7af41467dd622dc9add17f3ylavic # 1. parse netstat(1M) output for v4 interfaces in BOUND
f7317ff316c2b141feea31bddb74d5d3fa1584edjorton $2 ~ /BOUND/ { printf "%s ", $1 }
f7317ff316c2b141feea31bddb74d5d3fa1584edjorton $2 ~ /INFORMATION/ { printf "%s ", $1 }'
1e2d421a36999d292042a5539971070d54aa6c63ylavic# get_dhcpinfo <code/identifier>
1e2d421a36999d292042a5539971070d54aa6c63ylavic# echoes the value received through each interface controlled by DHCP
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh# 0 => property is set
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh# 1 => property is not set
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic if [ $? -eq 0 ]; then
15890c9306ba98f6fc243e15a3c4778ddc7d773erpluem# set_smf_prop <fmri> <property name> <property value>
cfd9415521847b2f9394fad04fb701cfb955f503rjung# refresh_svc <fmri>
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe# Refreshes the service.
63b9f1f5880391261705f696d7d65507bbe9ace3covener# restart_svc <fmri>
49dacedb6c387b786b7911082ff35121a45f414bcovener# Restarts the service.
fc42512879dd0504532f52fe5d0d0383dda96a1eniq# start_svc <fmri>
fc42512879dd0504532f52fe5d0d0383dda96a1eniq# Starts the service. If the service is already enabled, restarts it. If
0451df5dc50fa5d8b3e07d92ee6a92e36a1181a5niq# it is not enabled, temporarily enables it.
259878293a997ff49f5ddfc53d3739cbdc25444ecovener# stop_svc <fmri>
259878293a997ff49f5ddfc53d3739cbdc25444ecovener# Temporarily disables the service.
65967d05f839dbf27cf91d91fa79585eeae19660minfrin# copy_default <dir> <file>
65967d05f839dbf27cf91d91fa79585eeae19660minfrin# Copies <dir>/<file>.dfl to <dir>/<file>
8152945ae46857b170cb227e79bb799f4fc7710dminfrin $CP -p $1/$2.dfl $1/$2
75f5c2db254c0167a0e396254460de09b775d203trawick# do_dns <location>
4f0358189bfa57b8e75bd6b94db264302a8f336amrumph# Installs DNS information on /etc/resolv.conf for location
54d750a84a175d8e338880514d440773eb986b50covener DNS_CONFIGSRC=`nwam_get_loc_prop $loc dns-nameservice-configsrc`
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener echo "Unrecognized DNS configsrc ${configsrc}; ignoring"
111436a32ba1254291e4883292fb116d15fe8f64covener for (i = 1; i <= NF; i++) printf(" %s", $i); \
ccc20788c1e5fc973f36df634399c89acb70deaejerenkrantz # Finally, copy our working version to the real thing
fe83f60b41477b14a37edcfcd1f7f5c5a1ebfe44minfrin# do_nis <location>
993d1261a278d7322bccef219101220b7b4fb8c5jkaluza# Installs NIS information on /var/yp/binding/ for location
ba050a6f942b9fa0e81ed73437588005c569655ccovener NIS_CONFIGSRC=`nwam_get_loc_prop $loc nis-nameservice-configsrc`
efe780dcf13b2b95effabf897d694d8f23feac74trawick DEFAULT_DOMAIN=`nwam_get_loc_prop $loc default-domain`
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick echo "Unrecognized NIS configsrc ${configsrc}; ignoring"
75a230a728338d84dcfe81edd375352f34de22d0covener# do_ldap <location>
1f50dc34ae069adeed20b2986e5ffdefa5c410e0covener# Installs LDAP information using ldapclient(1M) for location
63a5ea80bddcc84a462e40f402b4f330e0e05411covener LDAP_CONFIGSRC=`nwam_get_loc_prop $loc ldap-nameservice-configsrc`
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin DEFAULT_DOMAIN=`nwam_get_loc_prop $loc default-domain`
a511a29faf2ff7ead3b67680154a624effb31aafminfrin echo "Unrecognized LDAP configsrc ${configsrc}; ignoring"
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrin # Use ldapclient(1M) to initialize LDAP client settings.
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrin if [ -n "$DEFAULT_DOMAIN" -o -n "$LDAP_SERVERS" ]; then
deec48c67d4786bc77112ffbf3a4e70b931097edminfrin # XXX need to check how to specify multiple LDAP servers.
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq# do_ns <location>
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq# Installs different nameservices for location
413ee814748f37be168ff12407fa6dba0ceeabe6trawick # Disable nameservices temporarily while we reconfigure. Copy
c12917da693bae4028a1d5a5e8224bceed8c739dsf # /etc/nsswitch.files to /etc/nsswitch.conf first so that only "files"
d7ffd2da16d58b1a0de212e4d56f7aebb72bef26sf # Remove /etc/defaultdomain and unset domainname(1M). If NIS
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf # and/or LDAP is configured, they will create /etc/defaultdomain
2a7beea91d46beb41f043a84eaad060047ee04aafabien missing nameservices-config-file property"
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick echo "Unrecognized nameservices value ${ns}; ignoring"
79c5787b92ac5f0e1cc82393816c77a006399316trawick # We explicitly restart here, as restart will only have an
79c5787b92ac5f0e1cc82393816c77a006399316trawick # effect if the service is already enabled. We don't want
536e48c08d674acac5d44929318f2ad928edc361jorton# do_sec <location>
e81785da447b469da66f218b3f0244aab507958djorton# If config properties are set, update the SMF property and refresh the
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton# service. If config properties are not set, delete the SMF property and
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton# stop the service.
53e9b27aba029b18be814df40bcf6f0428771d1efuankg pol_file=`nwam_get_loc_prop $loc ipsecpolicy-config-file`
6bb524f1895f30265a1431afc460977d391cb36bsf ipf6_file=`nwam_get_loc_prop $loc ipfilter-v6-config-file`
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin set_smf_prop $IPSEC_IKE_FMRI config/config_file $ike_file
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung set_smf_prop $IPSEC_POLICY_FMRI config/config_file $pol_file
refresh_ipf=true
refresh_ipf=true
refresh_ipf=true
refresh_ipf=true
domain=$1
loc=$1
if [ $? -eq 0 ]; then
loc=$1
echo activating $loc location
# location selection/activation happens below
# location selection/activation happens below
# 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
-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," \
# line of nsswitch.conf.
exit $SMF_EXIT_OK