> to emerge 25other unstables. -YUK

Emerging all these unstables caused some problems, primarily with the
net-apps/baselayout package. I fixed these, and now Gaim works with
Yahoo IM. Also has nice encryption plugin. 

After emerging all the new unstable packages, there were 51 files in
/etc/ to update. I'm lazy, so I wrote a throwaway shell script to
automatically copy the new one over if the only major differences were
the header lines. - If there are more differences than a set threshold,
it will prompt you to overwrite the old file.

-I successfully used the script several times, and attached it below,
but Now I can't see attachments in evolution, so I can only assume it's
being sent. Enjoy, YMMV.

-RYAN

-- 
Ryan Madison <[EMAIL PROTECTED]>
Simonson Technology Services
#!/bin/sh
#RHM 6/30/04
#Purpose: Script to update configuration files in /etc after an emerge on gentoo. 
#Action: Will update old with new automatically if differences are below threshold, otherwise, it
#will prompt for action from the user if they are slightly more different.
#
#To understand what's going on, type: sudo emerge --help config

#If environment variable $DEBUG set to 1, some extra echo statements are printed.
if [ "x$DEBUG" = "x" ] ; then
DEBUG=0
fi

#Function that replaces the old file with the new file and removes the old
replaceit() {
echo "Updating $OLDF..."
[ $DEBUG -eq 1 ] && diff $NEWF $OLDF
[ $DEBUG -eq 1 ] && read next
echo "cp $NEWF $OLDF" && cp $NEWF $OLDF
diff $NEWF $OLDF > /dev/null 2>&1
RET=$?
[ $RET -eq 0 ] && echo "rm $NEWF" && rm $NEWF
echo ""
}

#Echo statements to let you know what's going on.
#Run the find, and redirect to temporary file.
#Echo the number of files that need updating
echo "Finding files in /etc that need updating."
find /etc -iname '._cfg????_*' > /tmp/emergelist$$
FILELIST=/tmp/emergelist$$
echo "`wc -l $FILELIST | awk '{print $1}'` files need updating in /etc"

#Loop on list of files, and if less than or equal to 4 lines of difference, (hopefully only 
#indicating header change), then blindly copy the newfile over oldfile.
#Otherwise, if it's between 4 and 8 lines difference, prompt the user for interaction.

for R in `cat $FILELIST` ; do
OLDF=`echo $R | sed 's/\._cfg0000_//'`
NEWF=${R}
NUMCOMM=`comm -3 $NEWF $OLDF | sed '/^$/d' | wc -l`
if [ $NUMCOMM -le 4 ] ; then
echo "$NEWF & $OLDF have $NUMCOMM lines different."
replaceit
elif [ $NUMCOMM -le 7 -a $NUMCOMM -gt 4 ] ; then
  comm -3 $NEWF $OLDF | sed '/^$/d'
  echo "$NEWF & $OLDF have $NUMCOMM lines different."
  echo -n "Type y to copy $NEWF to $OLDF? Otherwise hit Enter > "
  read ANS
  case "${ANS}" in
   y|Y)
   replaceit
  ;;
   *)
   echo "No action taken..."
   echo ""
  esac
  ANS=N
  fi
done

#Count the files that are different again.
#Let the user know how many are left.
find /etc -iname '._cfg????_*' > /tmp/emergelistdone$$
FILELISTDONE=/tmp/emergelistdone$$
echo "There are `wc -l $FILELISTDONE | awk '{print $1}'` files that still need updating in /etc"
rm $FILELIST $FILELISTDONE

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
RLUG mailing list
[EMAIL PROTECTED]
http://lists.rlug.org/mailman/listinfo/rlug

Reply via email to