#!/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. # PATH="/usr/bin:/usr/sbin:${PATH}" export PATH # # This class action script is based on the fact that unique identifiers # used by Sun are reserved for Sun usage ONLY and can be removed or # updated as needed. # # User defined entries and comments in an existing inittab file will be # preserved and appended to the new ($src) inittab file. # # If there is no existing ($dest) inittab file, the script simply copies # the new ($src) inittab file into place. However, if there is an existing # ($dest) inittab file, the script attempts to strip out all Sun Reserved # lines, what remains should be the user defined entries and comments # which are subsequently appended to the new ($src) inittab file. # # The script works by generating two sets of sed parameters which # will strip out the Sun Reserved unique identifiers from the existing # inittab file. # # PRMVALCUR - a list of sed regular expressions generated from the # unique identifier field of the new ($src) inittab file. # # - this parameter list is generated from the $src inittab file by # stripping out all comment lines, taking the remaining lines which # match the regular expression /:(.*):(.*):/ and stripping out the # two character uniq id field, which is then used to construct a # a sed parameter list of the type '-e /^<uniq id>:/d' which will # delete out lines matching the uniq id. # # PRMVALOLD - sed regular expression removal parameters for old unique # identifier entries. These are here in case an existing unique # identifier is retired in some future version of the inittab file. # # - this parameter list is a static list which contains all # unique identifiers used by Solaris since 2.51 on both sparc and # x86. If a uniq id is retired from the inittab file it will no # longer be properly stripped via PRMVALCUR in an upgrade. This # parameter list insures that uniq id removals in the inittab will # not require modification of this class action script. This # script will only require modification if a new entry is made # to the inittab, which is subsequently removed. In which case # the uniq id of that entry should be added to this parameter list. # # The new ($src) inittab file is copied to a temporary location. The # existing ($dest) inittab file is then run through sed with the # parameters defined above. The results are then appended to the # temporary copy of the ($src) inittab, skipping anything before # '^#ident', which is where the Sun comment block ends. The results # are then copied back onto the original temp file to ensure file # ownership and permissions are preserved. This resulting file # representing the merge between the old and new inittab is then # copied into place. # # We also pick up any customizations of the ttymon invocation. ttymonopts() { ttymon_nohangup=false while getopts d:ghl:m:p:T:t: opt do case $opt in d) ttymon_device=$OPTARG ;; h) ttymon_nohangup=true ;; l) ttymon_label=$OPTARG ;; m) ttymon_modules=$OPTARG ;; p) ttymon_prompt=$OPTARG ;; T) ttymon_termtype=$OPTARG ;; t) ttymon_timeout=$OPTARG ;; *) ;; esac done } updatettymon() { SEDCMD='s+\`+\\\`+g;s+\$+\\\$+g;' TTYMONLINE="^co:234:respawn:/usr/lib/saf/ttymon" tmp=`grep $TTYMONLINE $dest | sed "s+$TTYMONLINE+ttymonopts+;$SEDCMD"` eval $tmp ttymon_prompt=`echo $ttymon_prompt | sed $SEDCMD` cat >> $PKG_INSTALL_ROOT/var/svc/profile/upgrade <<-EOFA ttymon_opt() { /usr/sbin/svccfg -f - <<-EOFB select system/console-login setprop ttymon/\$1 = "\$2" EOFB } [ -n "$ttymon_device" ] && ttymon_opt device "$ttymon_device" [ -n "$ttymon_nohangup" ] && ttymon_opt nohangup "$ttymon_nohangup" [ -n "$ttymon_label" ] && ttymon_opt label "$ttymon_label" [ -n "$ttymon_modules" ] && ttymon_opt modules "$ttymon_modules" [ -n "$ttymon_prompt" ] && ttymon_opt prompt "$ttymon_prompt" [ -n "$ttymon_termtype" ] && ttymon_opt terminal_type "$ttymon_termtype" [ -n "$ttymon_timeout" -a "$ttymon_timeout" -ne 0 ] && \ ttymon_opt timeout "$ttymon_timeout" /usr/sbin/svcadm refresh svc:/system/console-login:default EOFA } while read src dest; do if [ ! -f $dest ]; then cp -p $src $dest else updatettymon PRMVALCUR=`sed -e '/^#/d' $src | awk ' /^[^:]*:[^:]*:[^:]*:/{ split ($0,tmp,":"); if ( length ( tmp[1] ) > 0 && tmp[1] != $0 ) param=" -e /^" tmp[1] ":/d" param; } END { print param ; }'` PRMVALOLD=' -e /^co:/d -e /^sc:/d -e /^rb:/d -e /^of:/d -e /^fw:/d -e /^s6:/d -e /^s5:/d -e /^s3:/d -e /^s2:/d -e /^s1:/d -e /^s0:/d -e /^sS:/d -e /^p3:/d -e /^is:/d -e /^fs:/d -e /^ap:/d -e /^sp:/d ' cp -p $src /tmp/d1.$$ sed $PRMVALCUR $dest | sed $PRMVALOLD | awk ' /^#/ { if (end_sun_comments) print $0 } !/^#/ { end_sun_comments = 1; print $0 } ' >>/tmp/d1.$$ cp -p /tmp/d1.$$ $dest rm -f /tmp/d1.$$ fi done exit 0