i.inittab revision 7c478bd95313f5f23a4c958a745db2134aa03244
229ea4644b3a7d9c7fdaa43888e7f55ba01e2ee3Automatic Updater# CDDL HEADER START
1167fc7904c5f0a472f8df207ac46dd52c7f1ec8Automatic Updater# The contents of this file are subject to the terms of the
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater# Common Development and Distribution License, Version 1.0 only
46da3117812814a29432a8d9a9ccf8acdbfdadceAutomatic Updater# (the "License"). You may not use this file except in compliance
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater# with the License.
79b273c187a4aa1016a62181983dfdd0521681aeMark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90ff38a0d8deaf5f9c2aa5916d99b2e572d28738Automatic Updater# or http://www.opensolaris.org/os/licensing.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# See the License for the specific language governing permissions
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews# and limitations under the License.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# When distributing Covered Code, include this CDDL HEADER in each
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e171a4137c6ba348957e61b7c4c3541493c0da02Automatic Updater# If applicable, add the following below this CDDL HEADER, with the
e171a4137c6ba348957e61b7c4c3541493c0da02Automatic Updater# fields enclosed by brackets "[]" replaced with your own identifying
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# information: Portions Copyright [yyyy] [name of copyright owner]
3cc98b8ecedcbc8465f1cf2740b966b315662430Automatic Updater# CDDL HEADER END
e171a4137c6ba348957e61b7c4c3541493c0da02Automatic Updater#ident "%Z%%M% %I% %E% SMI"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Use is subject to license terms.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# This class action script is based on the fact that unique identifiers
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# used by Sun are reserved for Sun usage ONLY and can be removed or
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# updated as needed.
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater# User defined entries and comments in an existing inittab file will be
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# preserved and appended to the new ($src) inittab file.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# If there is no existing ($dest) inittab file, the script simply copies
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# the new ($src) inittab file into place. However, if there is an existing
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# ($dest) inittab file, the script attempts to strip out all Sun Reserved
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt# lines, what remains should be the user defined entries and comments
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater# which are subsequently appended to the new ($src) inittab file.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt# The script works by generating two sets of sed parameters which
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# will strip out the Sun Reserved unique identifiers from the existing
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# inittab file.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# PRMVALCUR - a list of sed regular expressions generated from the
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# unique identifier field of the new ($src) inittab file.
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater# - this parameter list is generated from the $src inittab file by
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# stripping out all comment lines, taking the remaining lines which
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# match the regular expression /:(.*):(.*):/ and stripping out the
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# two character uniq id field, which is then used to construct a
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# a sed parameter list of the type '-e /^<uniq id>:/d' which will
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews# delete out lines matching the uniq id.
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews# PRMVALOLD - sed regular expression removal parameters for old unique
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# identifier entries. These are here in case an existing unique
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater# identifier is retired in some future version of the inittab file.
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater# - this parameter list is a static list which contains all
8e9f3b69914ee02a80b87c97b1f8093edb3e9ae0Automatic Updater# unique identifiers used by Solaris since 2.51 on both sparc and
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# x86. If a uniq id is retired from the inittab file it will no
930f6069e5aa157cf6987cdafd412f5757a5a558Automatic Updater# longer be properly stripped via PRMVALCUR in an upgrade. This
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# parameter list insures that uniq id removals in the inittab will
930f6069e5aa157cf6987cdafd412f5757a5a558Automatic Updater# not require modification of this class action script. This
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater# script will only require modification if a new entry is made
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# to the inittab, which is subsequently removed. In which case
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater# the uniq id of that entry should be added to this parameter list.
930f6069e5aa157cf6987cdafd412f5757a5a558Automatic Updater# The new ($src) inittab file is copied to a temporary location. The
693c4232dfdffaff672197d4b9fea944c64cf80aAutomatic Updater# existing ($dest) inittab file is then run through sed with the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# parameters defined above. The results are then appended to the
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# temporary copy of the ($src) inittab, skipping anything before
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# '^#ident', which is where the Sun comment block ends. The results
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# are then copied back onto the original temp file to ensure file
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# ownership and permissions are preserved. This resulting file
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# representing the merge between the old and new inittab is then
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# copied into place.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# We also pick up any customizations of the ttymon invocation.
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater while getopts d:ghl:m:p:T:t: opt
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews TTYMONLINE="^co:234:respawn:/usr/lib/saf/ttymon"
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews tmp=`grep $TTYMONLINE $dest | sed "s+$TTYMONLINE+ttymonopts+;$SEDCMD"`
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews ttymon_prompt=`echo $ttymon_prompt | sed $SEDCMD`
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater cat >> $PKG_INSTALL_ROOT/var/svc/profile/upgrade <<-EOFA
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsttymon_opt() {
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater /usr/sbin/svccfg -f - <<-EOFB
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updaterselect system/console-login
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updatersetprop ttymon/\$1 = "\$2"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater[ -n "$ttymon_device" ] && ttymon_opt device "$ttymon_device"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater[ -n "$ttymon_nohangup" ] && ttymon_opt nohangup "$ttymon_nohangup"
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater[ -n "$ttymon_label" ] && ttymon_opt label "$ttymon_label"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater[ -n "$ttymon_modules" ] && ttymon_opt modules "$ttymon_modules"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater[ -n "$ttymon_prompt" ] && ttymon_opt prompt "$ttymon_prompt"
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson[ -n "$ttymon_termtype" ] && ttymon_opt terminal_type "$ttymon_termtype"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater[ -n "$ttymon_timeout" -a "$ttymon_timeout" -ne 0 ] && \
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews ttymon_opt timeout "$ttymon_timeout"
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater/usr/sbin/svcadm refresh svc:/system/console-login
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater if [ ! -f $dest ]; then
0ce87e5749aabb8eef1e0a37e4bd6e6ffa1d7196Automatic Updater /^[^:]*:[^:]*:[^:]*:/{ split ($0,tmp,":");
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater if ( length ( tmp[1] ) > 0 && tmp[1] != $0 )
229ea4644b3a7d9c7fdaa43888e7f55ba01e2ee3Automatic Updater param=" -e /^" tmp[1] ":/d" param;
da82e232161d67b77df2d67898bdac693f647be1Automatic Updater PRMVALOLD=' -e /^co:/d -e /^sc:/d -e /^rb:/d -e /^of:/d
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater -e /^fw:/d -e /^s6:/d -e /^s5:/d -e /^s3:/d
d145b64cacc8d9cda51f9924ec70cd4661c3e2cfAutomatic Updater -e /^s2:/d -e /^s1:/d -e /^s0:/d -e /^sS:/d
8711e5c73ca872d59810760af0332194cbdd619bAutomatic Updater -e /^p3:/d -e /^is:/d -e /^fs:/d -e /^ap:/d
da82e232161d67b77df2d67898bdac693f647be1Automatic Updater sed $PRMVALCUR $dest | sed $PRMVALOLD >/tmp/d2.$$
9c446b72069d0ab9f710502f4d7048e50875fccbAutomatic Updater if grep '^#ident' $dest >/dev/null 2>&1; then
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater /^#/ { if (end_sun_comments) print $0 }
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater !/^#/ { end_sun_comments = 1; print $0 }
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater /^#ident/ { end_sun_comments = 1 }