#!/bin/sh QUIET= if [ "$1" = "--quiet" ] ; then QUIET=on shift fi if [ "$1" = "--all" ] ; then if [ ! -x /root/logstory-listservers ] ; then echo Script /root/logstory-listservers do not exist echo Please create one which lists all servers to probe exit 1 else SERVERS=`/root/logstory-listservers` fi elif [ "$1" = "" ] ; then echo logstory-scanservers --all echo logstory-scanservers server1 ... exit 1 else SERVERS="$*" fi updateif(){ if cmp -s $1 $2 then # No change. We keep the original timestamp rm -f $2 else mv -f $2 $1 fi } mkdir -p /var/log/logstory ERROR=false cd /var/log/logstory for serv in $SERVERS do if [ "$QUIET" != "on" ]; then echo $serv fi if [ ! -f $serv.story ] ; then touch $serv.story fi if scp -q /usr/sbin/logstory-scan $serv:/root/logstory-scan then if ssh $serv /root/logstory-scan | logstory $serv.story - >$serv.story.new then updateif $serv.story $serv.story.new else echo "Can't ssh to server" $serv ERROR=true fi else echo "Can't scp /usr/sbin/logstory-scan to server" $serv ERROR=true fi done if [ "$ERROR" = "true" ] ; then echo "Not updating unused.file" else # Update the unused.file file with stuff which is not used if [ "$QUIET" != "on" ]; then echo Updating unused file... fi UNUSEDFILE=unused.file DEADSTUFF=deadstuff.file if [ ! -f $UNUSEDFILE ] ; then touch $UNUSEDFILE fi if [ ! -f $DEADSTUFF ] ; then touch $DEADSTUFF fi logstory --unused --deadstuff $DEADSTUFF *.story | logstory $UNUSEDFILE - >$UNUSEDFILE.new updateif $UNUSEDFILE $UNUSEDFILE.new fi