Cross Reference: /illumos-gate/usr/src/pkgdefs/common_files/i.inittab
i.inittab revision 7c478bd95313f5f23a4c958a745db2134aa03244
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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
#
#
#ident "%Z%%M% %I% %E% SMI"
#
# Copyright 2004 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
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 >/tmp/d2.$$
if grep '^#ident' $dest >/dev/null 2>&1; then
awk '
/^#/ { if (end_sun_comments) print $0 }
!/^#/ { end_sun_comments = 1; print $0 }
/^#ident/ { end_sun_comments = 1 }
' /tmp/d2.$$ >>/tmp/d1.$$
else
cat /tmp/d2.$$ >>/tmp/d1.$$
fi
cp -p /tmp/d1.$$ $dest
rm -f /tmp/d1.$$ /tmp/d2.$$
fi
done
exit 0