From 8134befe6816e06a68eb64f4708b68445e6e84e6 Mon Sep 17 00:00:00 2001 From: hjp Date: Thu, 17 Sep 1998 08:32:57 +0000 Subject: [PATCH] CVS cleanups: Added quotasanitycheck.pl and removed quotasanitycheck. Added quotasanitycheck --- quotacheck/GNUmakefile | 5 +- quotacheck/configure | 104 ++++++++++++++++++ .../{quotasanitycheck => quotasanitycheck.pl} | 23 ++-- 3 files changed, 120 insertions(+), 12 deletions(-) create mode 100755 quotacheck/configure rename quotacheck/{quotasanitycheck => quotasanitycheck.pl} (79%) mode change 100755 => 100644 diff --git a/quotacheck/GNUmakefile b/quotacheck/GNUmakefile index 61f028f..8a93bb6 100644 --- a/quotacheck/GNUmakefile +++ b/quotacheck/GNUmakefile @@ -1,9 +1,10 @@ include GNUmakevars -all: quotacheck quotastat quotasanitycheck +TARGETS = quotacheck quotastat quotasanitycheck +all: $(TARGETS) clean: - rm -f quotacheck *.bak + rm -f $(TARGETS) *.bak core foo bar baz *.ps distclean: clean rm -f customize diff --git a/quotacheck/configure b/quotacheck/configure new file mode 100755 index 0000000..5ec0bd1 --- /dev/null +++ b/quotacheck/configure @@ -0,0 +1,104 @@ +#!/bin/sh +# +echo "#!/bin/sh" > customize +echo "sed \\" > customize +chmod +x customize + +################################################################ +# find a working perl: +# +for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5 +do + if $i -e 'exit ($] < 5.000)' + then + echo $i works + perl="$i" + break + fi +done +if [ -z "$perl" ] +then + could not find a working perl command, sorry. + exit 1 +fi +echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize + + +################################################################ +# find a working df: +# +for i in /bin/df /usr/bin/df /usr/sbin/df /usr/local/bin/df +do + a=`$i | awk 'NR == 1 {print $2}'` + if [ "$a" = "kbytes" -o "$a" = "1024-blocks" ] + then + echo $i works + df="$i" + break + fi + a=`$i -k | awk 'NR == 1 {print $2}'` + if [ "$a" = "kbytes" -o "$a" = "1024-blocks" ] + then + echo $i -k works + df="$i -k" + break + fi +done +if [ -z "$df" ] +then + could not find a working df command, sorry. + exit 1 +fi +echo " -e 's,@@@df@@@,$df,g' \\" >> customize + +################################################################ +# find repquota: +# We don't try to check whether the output is useful, +# just check whether we can call it. You may need root +# privileges for this to succeed. +# +for i in /usr/sbin/repquota +do + if $i -a + then + echo $i works + repquota="$i" + break + fi +done +if [ -z "$repquota" ] +then + could not find a working repquota command, sorry. + exit 1 +fi +echo " -e 's,@@@repquota@@@,$repquota,g' \\" >> customize + +################################################################ +# find sendmail: +# We don't try to check whether the mail is actually delivered, +# just if sendmail accepts mail for a local user. +# This may not be a very useful test. +# +user=`whoami` +for i in /usr/sbin/sendmail /usr/lib/sendmail +do + if $i -t -i <> customize + diff --git a/quotacheck/quotasanitycheck b/quotacheck/quotasanitycheck.pl old mode 100755 new mode 100644 similarity index 79% rename from quotacheck/quotasanitycheck rename to quotacheck/quotasanitycheck.pl index 315f2a8..254c1c1 --- a/quotacheck/quotasanitycheck +++ b/quotacheck/quotasanitycheck.pl @@ -1,11 +1,11 @@ -#!/usr/bin/perl +#!@@@perl@@@ # -# $Id: quotasanitycheck,v 1.1 1998-09-17 07:30:12 hjp Exp $ -# $Log: quotasanitycheck,v $ -# Revision 1.1 1998-09-17 07:30:12 hjp -# Made messages more user friendly (and less admin friendly). -# allow grace time "NOT STARTED". -# added quotasanitycheck. +# $Id: quotasanitycheck.pl,v 1.1 1998-09-17 08:32:57 hjp Exp $ +# $Log: quotasanitycheck.pl,v $ +# Revision 1.1 1998-09-17 08:32:57 hjp +# CVS cleanups: +# Added quotasanitycheck.pl and removed quotasanitycheck. +# Added quotasanitycheck # # # check quotas for sanity: @@ -25,9 +25,12 @@ getopts('b:f:F:', \%opts); print "b=", $opts{'b'}, "f=", $opts{'f'}, "F=", $opts{'F'}, "\n"; +$blmin = $opts{'b'}; +$flmin = $opts{'f'}; + $hostname=`hostname`; chomp($hostname); -open (DF, "/usr/local/bin/df |") or die "cannot call /usr/local/bin/df: $!"; +open (DF, "@@@df@@@ |") or die "cannot call @@@df@@@: $!"; $fs = $/; undef ($/); @@ -40,7 +43,7 @@ $df =~ s/\n[ \t]+/ /mg; for $ln (@df) { ($fs, $total, $used, $free, $pct, $mount) = split(/\s+/, $ln); if ($fs =~ m|^/dev/|) { - open REPQUOTA, "/usr/sbin/repquota $mount 2>/dev/null |" or die "cannot call /usr/sbin/repquota: $!"; + open REPQUOTA, "@@@repquota@@@ $mount 2>/dev/null |" or die "cannot call @@@repquota@@@: $!"; while () { if (/(\w+) \s+ [-+][-+] \s* (\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours)|)\s+ @@ -73,7 +76,7 @@ for $ln (@df) { } print " file limit"; - print " soft: $flsoft hard $flhard"; + print " soft $flsoft hard $flhard"; if ($flsoft >= $flmin) { print " min_ok"; } else {