simple/quotacheck/configure

148 lines
3.1 KiB
Bash
Executable File

#!/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
echo 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/bin/bdf /usr/sbin/df /usr/local/bin/df
do
a=`$i | awk 'NR == 1 {print $2}'`
if [ "$a" = "kbytes" -o "$a" = "1024-blocks" -o "$a" = "1k-blocks" ]
then
echo $i works
df="$i"
break
fi
a=`$i -k | awk 'NR == 1 {print $2}'`
if [ "$a" = "kbytes" -o "$a" = "1024-blocks" -o "$a" = "1k-blocks" ]
then
echo $i -k works
df="$i -k"
break
fi
done
if [ -z "$df" ]
then
echo 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
echo 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 <<EOF
From: $user
To: $user
Subject: Testmail from configure (please ignore)
Test
EOF
then
echo $i works
sendmail="$i"
break
fi
done
if [ -z "$sendmail" ]
then
echo could not find a working sendmail command, sorry.
exit 1
fi
echo " -e 's,@@@sendmail@@@,$sendmail,g' \\" >> customize.$$
################################################################
# find scp command
#
touch scp.test.$$
for i in /usr/bin/scp /usr/local/bin/scp
do
rm -f scp.test.$$.new
if $i scp.test.$$ scp.test.$$.new
then
if [ -f scp.test.$$.new ]
then
echo $i works
scp="$i"
break
fi
fi
done
rm -f scp.test.$$ scp.test.$$.new
if [ -z "$scp" ]
then
echo could not find a working find command, sorry.
exit 1
fi
echo " -e 's,@@@scp@@@,$scp,g' \\" >> customize.$$
# $Log: configure,v $
# Revision 1.6 2005-09-29 10:54:52 hjp
# No real change.
#
# Revision 1.5 2005/03/29 10:03:14 hjp
# check for df changed - rebuilt.
#
# Revision 1.1 2005/01/07 16:01:34 hjp
# Added test for scp.
#
################################################################
# finish
# Add trailing newline and rename temp file to final name
#
echo >> customize.$$
mv customize.$$ customize