i.inittab revision 7c478bd95313f5f23a4c958a745db2134aa03244
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews#!/bin/sh
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater#
229ea4644b3a7d9c7fdaa43888e7f55ba01e2ee3Automatic Updater# CDDL HEADER START
229ea4644b3a7d9c7fdaa43888e7f55ba01e2ee3Automatic Updater#
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.
cd0aa2d941d1438fabb5337f1f38c49478edf71dAutomatic Updater#
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.
6c6a121295b30772cbf3dd75a51fb9d883051a0eAutomatic Updater#
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]
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater#
3cc98b8ecedcbc8465f1cf2740b966b315662430Automatic Updater# CDDL HEADER END
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews#
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews#
e171a4137c6ba348957e61b7c4c3541493c0da02Automatic Updater#ident "%Z%%M% %I% %E% SMI"
831f79c4310a7d38fc3475ccfff531b2b2535641Automatic Updater#
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Use is subject to license terms.
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews#
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
91216cff91b34c9ff6e846dc23f248219cafe660Andreas GustafssonPATH="/usr/bin:/usr/sbin:${PATH}"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterexport PATH
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson#
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.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt#
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.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt#
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.
2d2dc37599979c83495510f8af8d1756753aa2c5Automatic Updater#
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#
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#
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#
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.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews#
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.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews#
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.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson#
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# We also pick up any customizations of the ttymon invocation.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssonttymonopts() {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater ttymon_nohangup=false
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater while getopts d:ghl:m:p:T:t: opt
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater do
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews case $opt in
11af78f7dc35741bdab68dbab11b03daab005b28Automatic Updater d) ttymon_device=$OPTARG ;;
11af78f7dc35741bdab68dbab11b03daab005b28Automatic Updater h) ttymon_nohangup=true ;;
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews l) ttymon_label=$OPTARG ;;
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont m) ttymon_modules=$OPTARG ;;
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater p) ttymon_prompt=$OPTARG ;;
8ccd7da886e93cd490fcb6f4c4e98a6514f35820Automatic Updater T) ttymon_termtype=$OPTARG ;;
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont t) ttymon_timeout=$OPTARG ;;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews *) ;;
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater esac
a308b69ac66fadf66863484f301314d6e6a3f1d2Automatic Updater done
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews}
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews
08e3b6797706a13054bad749dea04e94b514b8e7Automatic Updaterupdatettymon() {
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater SEDCMD='s+\`+\\\`+g;s+\$+\\\$+g;'
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews TTYMONLINE="^co:234:respawn:/usr/lib/saf/ttymon"
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews tmp=`grep $TTYMONLINE $dest | sed "s+$TTYMONLINE+ttymonopts+;$SEDCMD"`
a308b69ac66fadf66863484f301314d6e6a3f1d2Automatic Updater eval $tmp
a308b69ac66fadf66863484f301314d6e6a3f1d2Automatic Updater
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews ttymon_prompt=`echo $ttymon_prompt | sed $SEDCMD`
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater cat >> $PKG_INSTALL_ROOT/var/svc/profile/upgrade <<-EOFA
82447d835d3ff5c658749b4e9b4f66166407b3eaAutomatic Updater
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsttymon_opt() {
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater /usr/sbin/svccfg -f - <<-EOFB
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updaterselect system/console-login
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updatersetprop ttymon/\$1 = "\$2"
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic UpdaterEOFB
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater}
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater
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"
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater/usr/sbin/svcadm refresh svc:/system/console-login
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic UpdaterEOFA
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater}
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updaterwhile read src dest; do
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater if [ ! -f $dest ]; then
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson cp -p $src $dest
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater else
4104e236f71eb5108fcfda6711878a97f6f4a8e7Automatic Updater updatettymon
8711e5c73ca872d59810760af0332194cbdd619bAutomatic Updater
229ea4644b3a7d9c7fdaa43888e7f55ba01e2ee3Automatic Updater PRMVALCUR=`sed -e '/^#/d' $src | awk '
0ce87e5749aabb8eef1e0a37e4bd6e6ffa1d7196Automatic Updater /^[^:]*:[^:]*:[^:]*:/{ split ($0,tmp,":");
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater if ( length ( tmp[1] ) > 0 && tmp[1] != $0 )
229ea4644b3a7d9c7fdaa43888e7f55ba01e2ee3Automatic Updater param=" -e /^" tmp[1] ":/d" param;
765c97d56ccddc9d7904c7d9ff2e2d825d9687e4Automatic Updater }
3e5340279d8875d136a4dd815cccad0044aa2644Automatic Updater END { print param ; }'`
8ccd7da886e93cd490fcb6f4c4e98a6514f35820Automatic Updater
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
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater -e /^sp:/d '
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater cp -p $src /tmp/d1.$$
da82e232161d67b77df2d67898bdac693f647be1Automatic Updater sed $PRMVALCUR $dest | sed $PRMVALOLD >/tmp/d2.$$
9c446b72069d0ab9f710502f4d7048e50875fccbAutomatic Updater if grep '^#ident' $dest >/dev/null 2>&1; then
e85565067cf73f8cc21ee29b11761659f1d47ee9Automatic Updater awk '
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater /^#/ { if (end_sun_comments) print $0 }
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater !/^#/ { end_sun_comments = 1; print $0 }
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater /^#ident/ { end_sun_comments = 1 }
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater ' /tmp/d2.$$ >>/tmp/d1.$$
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater else
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater cat /tmp/d2.$$ >>/tmp/d1.$$
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater fi
7f79131f9a8e804b93c57f3c679065cce878b726Automatic Updater cp -p /tmp/d1.$$ $dest
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater rm -f /tmp/d1.$$ /tmp/d2.$$
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater fi
3f616e6f846be57b1717c6beaba0f74de9d5a7c6Automatic Updaterdone
da82e232161d67b77df2d67898bdac693f647be1Automatic Updater
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterexit 0
19b3dc94bce93fa76bd7e066f9298630dbc9dcb4Automatic Updater