#!/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 (c) 1993-2001 by Sun Microsystems, Inc. # All rights reserved. # PATH="/usr/bin:/usr/sbin:${PATH}" export PATH # # During an upgrade this class action script merges user modifications # in the original ($dest) /etc/default/login into the new replacement # /etc/default/login ($src) file. # # If there is no existing ($dest) login file, the script simply copies # the new ($src) default login file into place. However, if there is an # existing ($dest) login file, the script greps out each line which sets # a parameter in the original file and overwrites the corresponding line # in the new ($src) file. Since the entire line is ripped from the ($dest) # original, the state of being commented or uncommented is implicitly passed # along into the replacement ($src) file. # # The script works by looping through each variable name, grepping out # the apropos line, and creating a sed line, which when applied to the # replacement ($src) file will preserve modifications in the original # ($dest) file. # # We grep for both the commented keyword and the uncommented keyword. We # pipe this grep through a 'tail -1' to insure that only one (1) line is # returned. Multiple lines will spoil the sed pattern, and we use a # tail because the last uncommented ENV setting is the one which will take. # Although multiple entries ( commented or uncommented ) are possible we # preserve only the active ( uncommented ) entries. The preservation is # accomplished by building a file of sed actions, which when applied to # the new login file ($src) preserves the original ($dest) file settings. # # The logic for this merge is as follows: # # If both an active ( uncommented ) entry and an inactive ( commented ) # exist, we preserve the active entry and discard the inactive entry. # # If only an active ( uncommented ) entry exists we preserve the active # entry. # # If only an inactive ( commented ) entry exists we preserve the inactive # entry. NOTE - the fact that a variable is commented out must be preserved # because it too may be a user modification. # while read src dest do if [ ! -f $dest ] ; then cp -p $src $dest else sedfile=/tmp/sftmp.$$ cat /dev/null > $sedfile for word in TIMEZONE ULIMIT CONSOLE PASSREQ ALTSHELL \ PATH SUPATH TIMEOUT UMASK SYSLOG SLEEPTIME DISABLETIME \ RETRIES SYSLOG_FAILED_LOGINS; do oldline1=`grep "^$word=" $dest | tail -1 2> /dev/null` oldline2=`grep "^#[ ]*$word=" $dest | tail -1 2> /dev/null` if [ -n "$oldline1" ]; then echo "s|^[# ]*$word=.*|$oldline1|" >> $sedfile elif [ -n "$oldline2" ]; then echo "s|^[# ]*$word=.*|$oldline2|" >> $sedfile fi done sed -f $sedfile $src > $dest rm -f $sedfile fi done exit 0