#!/bin/sh # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Set path # PATH="/usr/bin:/usr/sbin:${PATH}" export PATH # # Set variables # BASEDIR=${BASEDIR:-/} FAILURE=1 MODULE="ii" OS_VER=`eval uname -r` OS_MACH=`eval isainfo -k` PKG_INSTALL_ROOT=${PKG_INSTALL_ROOT:=/} DEVLINKTB="${PKG_INSTALL_ROOT}/etc/devlink.tab" DRVDIR64=${PKG_INSTALL_ROOT}/usr/kernel/drv/${OS_MACH} DRVDIR=${PKG_INSTALL_ROOT}/usr/kernel/drv TMP=/tmp/${PKGINST}.$$ ERROR_LOG=${TMP}.errorlog DSCFG_UPGRADE="${PKG_INSTALL_ROOT}/etc/opt/SUNWesm/dscfg.cf.upgrade" FS_LOCAL_SVC="svc:/system/filesystem/local" EXIT=0 MODBUSY=0 MODBUSYMSG=" #### NOTICE #####\n The previous version of this software cannot be unloaded (busy).\n To load the new modules you must reboot the system." # # Set specific command syntax (if needed) # release=`uname -r | sed -e "s/[0-9]*\.//" -e "s/\..*//"` case $release in 1[0-9] ) REM_DRV="rem_drv -b ${PKG_INSTALL_ROOT}" ADD_DRV="add_drv -P sys_devices,sys_config -b ${PKG_INSTALL_ROOT}" ;; * ) REM_DRV="rem_drv -b ${PKG_INSTALL_ROOT}" ADD_DRV="add_drv -b ${PKG_INSTALL_ROOT}" cat >> $BASEDIR/etc/rc2.d/S99storage <<\_SCMU MODULES="ii" for MODULE in ${MODULES} do ADDERR="ERROR: The installation cannot be completed due to an error updating the \ ${MODULE} loadable module. The file ${ERRLOG} contains the errors. Exiting...\ Please fix problem and re-run pkgadd." update_drv -a -P sys_devices,sys_config -m '* 0666 root sys' $M ODULE 2>&1 [ $? -ne 0 ] && { message ${ADDERR} exit 1 } done _SCMU chmod a+x $BASEDIR/etc/rc2.d/S99storage ;; esac # # Functions # message() { echo "" echo "$@" echo "" } add_devlink() { PATTERN="$1" LINK="$2" echo "$PATTERN\t$LINK" >>${DEVLINKTB} } # # Setup the service to enable. This is necessary to deal # with upgrade situations. It also sets the proper dependency type for the # local filesystems service # $1: name of service to enable # enable_service_on_reboot() { cat >> $BASEDIR/var/svc/profile/upgrade <<\_SUNWiiu_reboot # enable the service svcadm enable -s svc:/system/$1 if [ $? -ne 0 ] then message "Warning: Unable to enable $1 service" fi # workaround for 6221374--let local-fs know that it depends on us svcadm refresh ${FS_LOCAL_SVC}:default if [ $? -ne 0 ] then message "Warning: Unable to refresh $1 service" fi # make sure the local filesystems service waits for us svccfg -s $FS_LOCAL_SVC setprop ${1}-local-fs/grouping=require_all if [ $? -ne 0 ] then message "Warning: Unable to set dependency for $1 service" fi svcadm refresh ${FS_LOCAL_SVC}:default if [ $? -ne 0 ] then message "Warning: Unable to refresh $1 service" fi _SUNWiiu_reboot } # if the main module is still loaded then it has refused to unload # and we have to force a reboot. # if [ "${PKG_INSTALL_ROOT:-/}" = "/" ]; then modinfo | grep -w ii >/dev/null 2>&1 if [ $? -eq 0 ]; then # still loaded MODBUSY=1 NOPT="-b / " fi fi # # Error messages # REMERR=" ERROR: The installation cannot be completed due to an error removing the ${MODULE} loadable module. The file ${ERROR_LOG} contains the errors. Exiting...Please fix problem and re-run pkgadd." ADDERR=" ERROR: The installation cannot be completed due to an error adding the ${MODULE} loadable module. The file ${ERROR_LOG} contains the errors. Exiting...Please fix problem and re-run pkgadd." DEVLINKERR=" ERROR: The installation cannot be completed due to an error configuring the ${MODULE} loadable module. The file ${ERROR_LOG} contains the errors. Exiting...Please fix problem and re-run pkgadd." # # If module has been previously installed, unload it and remove it... # grep -w ${MODULE} ${PKG_INSTALL_ROOT}/etc/name_to_major > /dev/null if [ $? -eq 0 ] then ${REM_DRV} ${MODULE} > ${ERROR_LOG} 2>&1 [ $? -ne 0 ] && { message "${REMERR}" exit ${FAILURE} } fi # # Install the module # add_devlink "type=ddi_pseudo;name=${MODULE}" '\D' ${ADD_DRV} $NOPT -m '* 0666 root sys' ${MODULE} > ${ERROR_LOG} 2>&1 [ $? -ne 0 ] && { message "${ADDERR}" exit ${FAILURE} } # deal with upgrades from AVS 3.2 if [ -f $DSCFG_UPGRADE ] then grep $PKGINST $DSCFG_UPGRADE > /dev/null if [ $? = 1 ] then enable_service_on_reboot nws_ii echo "$PKGINST" >> $DSCFG_UPGRADE fi fi if [ $MODBUSY = 1 ]; then message $MODBUSYMSG fi