Home | History | Annotate | Download | only in SUNWcnetr
      1 #
      2 # CDDL HEADER START
      3 #
      4 # The contents of this file are subject to the terms of the
      5 # Common Development and Distribution License (the "License").
      6 # You may not use this file except in compliance with the License.
      7 #
      8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9 # or http://www.opensolaris.org/os/licensing.
     10 # See the License for the specific language governing permissions
     11 # and limitations under the License.
     12 #
     13 # When distributing Covered Code, include this CDDL HEADER in each
     14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15 # If applicable, add the following below this CDDL HEADER, with the
     16 # fields enclosed by brackets "[]" replaced with your own identifying
     17 # information: Portions Copyright [yyyy] [name of copyright owner]
     18 #
     19 # CDDL HEADER END
     20 #
     21 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     22 # Use is subject to license terms.
     23 #
     24 # ident	"%Z%%M%	%I%	%E% SMI"
     25 #
     26 
     27 #
     28 # Convert datalink configuration into a series of dladm(1M) commands and
     29 # keep them in an upgrade script. This script will then be run in the
     30 # network-physical service.
     31 #
     32 # Note that we cannot use the /var/svc/profile/upgrade script because
     33 # that script is run during manifest-import which is too late for
     34 # datalink configuration.
     35 #
     36 UPGRADE_SCRIPT=/var/svc/profile/upgrade_datalink
     37 
     38 AGGR_CONF=/etc/aggregation.conf
     39 ORIG=$BASEDIR/$AGGR_CONF
     40 if [ ! -f "${ORIG}" ]; then
     41 	# Try the alternate location.
     42 	AGGR_CONF=/etc/dladm/aggregation.conf
     43 	ORIG=$BASEDIR/$AGGR_CONF
     44 fi
     45 
     46 # Now upgrade aggregation.conf to the new format.
     47 if [ -f "${ORIG}" ]; then
     48 	# Strip off comments, then each remaining line defines an
     49 	# aggregation the admnistrator configured on the old system.
     50 	# Each line corresponds to one dladm command that is appended
     51 	# to the upgrade script.
     52 	cat $ORIG | grep '^[^#]' | while read line; do
     53 		echo $line | while read aggr_index rest
     54 		do
     55 			policy=`echo $rest | /usr/bin/awk '{print $1}'`
     56 			nports=`echo $rest | /usr/bin/awk '{print $2}'`
     57 			ports=`echo $rest | /usr/bin/awk '{print $3}'`
     58 			mac=`echo $rest | /usr/bin/awk '{print $4}'`
     59 			lacp_mode=`echo $rest | /usr/bin/awk '{print $5}'`
     60 			lacp_timer=`echo $rest | /usr/bin/awk '{print $6}'`
     61 			dladm_string="dladm create-aggr -P $policy -l \
     62 			    $lacp_mode -T $lacp_timer"
     63 			# A fixed MAC address
     64 			if [ "${mac}" != "auto" ]; then
     65 				dladm_string="$dladm_string -u $mac"
     66 			fi
     67 			i=1
     68 			while [ $i -le "${nports}" ]; do
     69 				device=`echo $ports | cut -d, -f$i`
     70 				# Older aggregation.conf files have the format
     71 				# of device_name/port_number.  We don't need
     72 				# the port number, so get rid of it if it is
     73 				# there.
     74 				device=`echo $device | cut -d/ -f1`
     75 				i=`expr $i + 1`
     76 				dladm_string="$dladm_string -d $device"
     77 			done
     78 			dladm_string="$dladm_string $aggr_index"
     79 			echo $dladm_string >> \
     80 			    ${PKG_INSTALL_ROOT}/$UPGRADE_SCRIPT
     81 		done
     82 	done
     83 	# no longer needed, get rid of it.
     84 	rm -f $ORIG
     85 	removef $PKGINST $AGGR_CONF > /dev/null
     86 	removef -f $PKGINST > /dev/null 2>&1
     87 fi
     88 
     89 # Upgrade linkprop.conf
     90 ORIG=$BASEDIR/etc/dladm/linkprop.conf
     91 
     92 if [ -f "${ORIG}" ]; then
     93 	# Strip off comments, then each remaining line lists properties
     94 	# the administrator configured for a particular interface.
     95 	# Each line includes several properties, but we can only set
     96 	# one property per dladm invocation.
     97 	cat $ORIG | grep '^[^#]' | while read line; do
     98 		echo $line | while read link rest
     99 		do
    100 			while [ -n "${rest}" ]; do
    101 				linkprop=`echo $rest | cut -d";" -f1`
    102 				rest=`echo $rest | cut -d";" -f2-`
    103 				echo dladm set-linkprop -p $linkprop $link >> \
    104 				    ${PKG_INSTALL_ROOT}/$UPGRADE_SCRIPT
    105 			done
    106 		done
    107 	done
    108 	# no longer needed, get rid of it
    109 	rm -f $ORIG
    110 	removef $PKGINST /etc/dladm/linkprop.conf > /dev/null
    111 	removef -f $PKGINST > /dev/null 2>&1
    112 fi
    113 
    114 #
    115 # Change permissions of public IKE certificates and CRLs
    116 # that may have been incorrectly created as private
    117 # PKCS#11 hints files must be left root-only readable.
    118 # Make sure this files starts with "30 82"
    119 #
    120 for file in `ls ${PKG_INSTALL_ROOT}/etc/inet/ike/crls/* \
    121     ${PKG_INSTALL_ROOT}/etc/inet/ike/publickeys/* 2>/dev/null`; do
    122 	if /bin/od -tx1 -N3 < $file | grep '30 82' >/dev/null 2>&1
    123 	then
    124 	    chmod 644 $file
    125 	fi
    126 done
    127 exit 0
    128