1 #!/bin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License, Version 1.0 only 7 # (the "License"). You may not use this file except in compliance 8 # with the License. 9 # 10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 # or http://www.opensolaris.org/os/licensing. 12 # See the License for the specific language governing permissions 13 # and limitations under the License. 14 # 15 # When distributing Covered Code, include this CDDL HEADER in each 16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 # If applicable, add the following below this CDDL HEADER, with the 18 # fields enclosed by brackets "[]" replaced with your own identifying 19 # information: Portions Copyright [yyyy] [name of copyright owner] 20 # 21 # CDDL HEADER END 22 # 23 # 24 #ident "%Z%%M% %I% %E% SMI" 25 # 26 # Copyright 2004 Sun Microsystems, Inc. All rights reserved. 27 # Use is subject to license terms. 28 # 29 30 # Get parameter value from old ata.conf file. 31 # Syntax: file parameter-name 32 getval() 33 { 34 # Strip all instances of ';' putval() will add exactly one. 35 sed -n "/^[ ]*[^#]/s/.*$2[ ]*=[ ]*\([^ ;]*\).*/\1/p" $1 \ 36 | head -1 37 } 38 39 # Put old parameter value into new ata.conf file. 40 # Syntax: file parameter-name value 41 putval() 42 { 43 # If new parameter-value pair, append it to the file. 44 grep "^[ ]*$2" $1 >/dev/null 45 if [ $? -eq 0 ] 46 then 47 sed "/^[ ]*[^#]/s/\($2[ ]*=[ ]*\)[^ ]*/\1$3;/" \ 48 $1 > /tmp/tmp.$$ 49 mv /tmp/tmp.$$ $1 50 else 51 echo "$2=$3;" >>$1 52 fi 53 } 54 55 while read src dest 56 do 57 if [ ! -f $dest ] ; then 58 # no existing version, just copy in new one 59 cp $src $dest 60 else 61 # Save existing values of the following parameters. 62 # Copy new ata.conf over current configuration file. 63 # Restore saved parameters in the new ata.conf file. 64 # 65 standby=`getval $dest standby` 66 drive0_block_factor=`getval $dest drive0_block_factor` 67 drive1_block_factor=`getval $dest drive1_block_factor` 68 timing_flags=`getval $dest timing_flags` 69 cp $src $dest 70 71 if [ -n "$standby" ] 72 then 73 putval $dest standby $standby 74 fi 75 if [ -n "$drive0_block_factor" ] 76 then 77 putval $dest drive0_block_factor $drive0_block_factor 78 fi 79 if [ -n "$drive1_block_factor" ] 80 then 81 putval $dest drive1_block_factor $drive1_block_factor 82 fi 83 if [ -n "$timing_flags" ] 84 then 85 putval $dest timing_flags $timing_flags 86 fi 87 fi 88 done 89 exit 0 90