Date: Sat, 20 Jun 1998 18:00:32 +0930 From: Matthew Thyer <thyerm@camtech.net.au> To: joelh@gnu.org Cc: freebsd-current@FreeBSD.ORG Subject: Re: /etc maintainence Message-ID: <358B7328.207EAA5A@camtech.net.au> References: <199806190349.WAA07258@detlev.UUCP>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------FA576F94599DE84816A2BDC5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I use my quick and dirty script "etcud" which I have attached. Although some of the other solutions a probably more 'correct' such as "Making the world your own" by Nik Clayton: (http://www.nothing-going-on.demon.co.uk/FreeBSD/make-world/make-world.html) I think my script is what most people actually do. Run it as "etcud -t -v" and it will do a typical run which will show you which files mismatch (md5 checksums) giving their version numbers so you can see if the mismatch is due to your edits or an update of the file. Other features: - it is platform aware and should run on i386 and alpha with no changes. - it allows you to check just a subset of the files under /usr/src/etc if you want using egrep patterns. - It knows to ignore files called Makefile and it knows the proper location for MAKEDEV etc. Read the comments at the top of the script or just run it as "etcud -h" for usage. Which is: Usage: etcud [-a] [-v] [-d] [-n] [-t] [-r <dir>] [-i <patt> | -e <patt>] -a Also output information for files where the checksums match -v Display RCS version strings if present -d Display diffs between the files -n Non-exact mode - i.e. dont use '-x' with egrep -t Typical usage. This is the same as etcud -e "group|hosts|motd|shells|rc.local|master.passwd" -r <dir> Directory where the source distribution is found -i <patt> Inclusion filename pattern (those files to check) -e <patt> Exclusion filename pattern (those file to ignore) Joel Ray Holveck wrote: > > Who has tools (even halfhearted perl scripts) to make -current /etc > maintainance easier? Eg, adding/changing entries in crontab to keep > up with -current, while maintaining your own local entries? > > Happy hacking, > joelh > > -- > Joel Ray Holveck - joelh@gnu.org - http://www.wp.com/piquan > Fourth law of programming: > Anything that can go wrong wi > sendmail: segmentation violation - core dumped > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message -- /=====================================================================\ |Work: Matthew.Thyer@dsto.defence.gov.au | Home: thyerm@camtech.net.au| \=====================================================================/ "If it is true that our Universe has a zero net value for all conserved quantities, then it may simply be a fluctuation of the vacuum of some larger space in which our Universe is imbedded. In answer to the question of why it happened, I offer the modest proposal that our Universe is simply one of those things which happen from time to time." E. P. Tryon from "Nature" Vol.246 Dec.14, 1973 --------------FA576F94599DE84816A2BDC5 Content-Type: text/plain; charset=us-ascii; name="etcud" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="etcud" #!/bin/sh # # etcud 2.0 - Compare /etc with /usr/src/etc to check for updated files (for # this machines hardware platform). # # etcud [-a] [-v] [-d] [-n] [-t] [-r <directory>] [-i <pattern> | -e <pattern>] # # This script compares the MD5 checksums of all files found in the etc # directory of the source distribution (/usr/src/etc by default) with # those in /etc to alert you when /etc files need updating. # # Options: # # -a Also output information for files where the checksums match. # -v Display RCS version strings if present. # -d Display diffs between the files. # -n Non-exact mode. i.e. dont use '-x' with egrep for inclusion # and exclusion patterns. For power users only! # -t Typical usage. This is the same as etcud -e $DEF_EXCL # -r <dir> Set the root directory of the source distribution. # -i <patt> Inclusion filename pattern (those files to check). # -e <patt> Exclusion filename pattern (those file to ignore). # # Inclusion and exclusion patterns must be an egrep pattern which is a list # of file names separated by the pipe character. The filenames must be # relative to the etc directory of the source distribution (/usr/src/etc # by default). # # By default the script will use egrep -x which means the patterns must # exactly match for the files to be included or excluded. This is # generally what you want as you probably want to be able to type # "etcud -e hosts" to exclude the file /etc/hosts but not the file # /etc/hosts.lpd. Power users can use -n to disable the use of -x # with egrep. This can be useful when dealing with the ppp directory # for example. # # NOTES # - You can use EITHER an exclusion OR an inclusion file pattern, not # both. Subsequent uses will be ignored with a warning. # # - Use of the typical option (-t) will run etcud with the default # exclusion pattern, set at $DEF_EXCL below. This mode overrides # any previously specified inclusion or exclusion patterns with a # warning. This mode also silently ignores -n. # # - Version 2.0 - a minor cosmetic fix. # # - Version 1.9 knows what this platform is when dealing with platform # specific directories (e.g. /usr/src/etc/etc.i386). It ignores # subdirectories in /usr/src/etc that start with 'etc.' other than # etc.`uname -m` (by default). # # - Previous versions were not worth mentioning (including my first attempt # sent in as a pr). # # AUTHOR: Matthew Thyer 1997, 1998 # ############################################################################### # The default directory for the source distribution DEF_SRC_ROOT=/usr/src # The typical exclusion list DEF_EXCL="group|hosts|motd|shells|rc.local|master.passwd" # # You shouldn't change this unless you want to make your /etc for another # platform (e.g. put PLATFORM=alpha) PLATFORM=`uname -m` # opt_all=0 opt_ver=0 opt_diffs=0 opt_non_exact=0 opt_typical=0 opt_inc=0 opt_exc=0 error=0 cmd_name=`basename $0` usage () { echo "Usage: $cmd_name [-a] [-v] [-d] [-n] [-t] [-r <dir>] [-i <patt> | -e <patt>]" echo " -a Also output information for files where the checksums match" echo " -v Display RCS version strings if present" echo " -d Display diffs between the files" echo " -n Non-exact mode - i.e. dont use '-x' with egrep" echo " -t Typical usage. This is the same as etcud -e \"$DEF_EXCL\"" echo " -r <dir> Directory where the source distribution is found" echo " -i <patt> Inclusion filename pattern (those files to check)" echo " -e <patt> Exclusion filename pattern (those file to ignore)" } show_ver () { the_ver=`grep '$Id:' $src_files/$x` if [ $? -eq 0 ] ; then echo "$src_files/$x VER> $the_ver" fi the_ver=`grep '$Id:' $the_file` if [ $? -eq 0 ] ; then echo " $the_file VER> $the_ver" fi } do_check () { # First determine if we should check this file (and what its home is) case $x in etc\.${PLATFORM}/MAKEDEV) the_file=/dev/MAKEDEV ;; etc\.${PLATFORM}/*) the_file=/etc/`echo $x | awk -F/ '{print $NF}'` ;; etc\.*/*) the_file=SKIP ;; *Makefile) the_file=SKIP ;; MAKEDEV\.local) the_file=/dev/MAKEDEV.local ;; *) the_file=/etc/$x ;; esac if [ $the_file != SKIP ] ; then if [ -r $the_file ] ; then if [ `md5 $the_file | cut -d' ' -f4` != `md5 $src_files/$x | cut -d' ' -f4` ] ; then echo MISMATCH for $src_files/$x $the_file if [ $opt_ver -eq 1 ] ; then show_ver fi if [ $opt_diffs -eq 1 ] ; then diff $the_file $src_files/$x echo fi elif [ $opt_all -eq 1 ] ; then echo CHECK OK for $src_files/$x $the_file if [ $opt_ver -eq 1 ] ; then show_ver fi fi else # the file is not readable.... why ? perhaps it doesn't exist if [ ! -f $the_file ] ; then echo NONEXISTANT $the_file. Maybe you should cp -p $src_files/$x $the_file else echo -n $the_file is not readable.... fi fi fi } # The main program begins..... # First get the options while [ $# -ne 0 ] ; do case $1 in -a) opt_all=1 ;; -v) opt_ver=1 ;; -d) opt_diffs=1 ;; -n) opt_non_exact=1 ;; -t) opt_typical=1 if [ $opt_inc -eq 1 -o $opt_exc -eq 1 ] ; then echo "Warning: Typical usage overriding prior inclusion or exclusion pattern" opt_inc=0 fi opt_exc=1 patt=$DEF_EXCL ;; -r) shift if [ $# -eq 0 ] ; then error=1 echo "Error: -r requires an argument" usage break else if [ -d $1 ] ; then SRC_ROOT=$1 else error=1 echo "Error: Source directory \"$1\" does not exist" usage break fi fi ;; -i) shift if [ $# -eq 0 ] ; then error=1 echo "Error: -i requires an argument" usage break else if [ $opt_inc -eq 1 -o $opt_exc -eq 1 ] ; then echo "Warning: subsequent inclusion pattern ignored" else patt=$1 opt_inc=1 fi fi ;; -e) shift if [ $# -eq 0 ] ; then error=1 echo "Error: -e requires an argument" usage break else if [ $opt_inc -eq 1 -o $opt_exc -eq 1 ] ; then echo "Warning: subsequent exclusion pattern ignored" else patt=$1 opt_exc=1 fi fi ;; *) error=1 usage break ;; esac shift done if [ $error -eq 1 ] ; then exit fi src_files=`echo ${SRC_ROOT:=$DEF_SRC_ROOT}/etc | sed 's/\/\//\//'` cd $src_files # Can only do non_exact mode if we are not doing a typical egrep_flags="-x" if [ $opt_non_exact -eq 1 -a $opt_typical -eq 0 ] ; then egrep_flags="" fi if [ $opt_exc -eq 1 ] ; then egrep_flags=$egrep_flags" -v " fi if [ $opt_inc -eq 1 -o $opt_exc -eq 1 ] ; then find . -type f -exec echo {} \; | sed 's/^\.\///' | egrep $egrep_flags $patt | while read x ; do do_check done else find . -type f -exec echo {} \; | sed 's/^\.\///' | while read x ; do do_check done fi --------------FA576F94599DE84816A2BDC5-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?358B7328.207EAA5A>