In article <[EMAIL PROTECTED]>, martin f krafft <[EMAIL PROTECTED]> wrote: >I am in search for a tool that does the following. > >- According to a list of users, the tool goes and finds a particular > file relative to the user's home directory. Let's say this file is > called foo.rc. If the user list consists of {bob, jane, bill}, then > the tool would go and find > > ~bob/foo.rc > ~jane/foo.rc > ~bill/foo.rc > >- Before doing anything with the file, the tool then checks directory > somewhere under /var for a previous version of the file, e.g. > > /var/spool/tool/bob/foo.rc > /var/spool/tool/jane/foo.rc > /var/spool/tool/bill/foo.rc > > * If a previous file is found, the tool generates a diff and > mails it to root. > >- The tool then copies the file from the user's homedirectory to > /var/spool/tool/<user>/foo.rc. > >That's it. Conceptually very simple, isn't it? I could write a shell >script, although perl might be better. But I want to know if there is >something like that out there already. > >Or if someone more capable on perl than I (i.e. > 0) could whip that >out of his/her pocket for my perusal. I'll package it and give credit >in return.
There are not things you should package. It's a one-off that you, as a capable sysadmin ;), should be able to write in less time as it took for you to compose this message. #! /bin/sh # # Usage: tool <backup dir> <config file> <user> [user ..] # DIR=$1 RC=$2 shift; shift for i in $* do HDIR=`eval echo ~$i` if [ -f $HDIR/$RC ] then if [ ! -d $DIR/$i ] then mkdir $DIR/$i fi if [ ! -f $DIR/$i/$RC ] then cp -a $HDIR/$RC $DIR/$i echo "** User $i:" echo "== Initial copy of $HDIR/$RC to $DIR/$i .. OK" elif ! cmp -s $HDIR/$RC $DIR/$i/$RC then echo "** User $i:" echo "== $HDIR/$RC differs from backup $DIR/$i/$RC :" diff -u $DIR/$i $HDIR/$RC echo cp -a $HDIR/$RC $DIR/$i fi fi done | mail -s "Tool output" root -- Anyone who is capable of getting themselves made President should on no account be allowed to do the job -- Douglas Adams. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]