1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
#!/bin/bash
# renattach configuration script
# Copyright(C) 2001, Jem E. Berkes
# http://www.pc-tools.net/
# By default we look for sendmail (MTA) and procmail (local mailer)
# To specify an exact location, override with --sendmail and --procmail
OUR_MTA=sendmail
OUR_LM=procmail
# More defaults, where things will be installed
prefix=
bindir=/usr/sbin
sysconfdir=/etc
####
echo
echo "Configuring renattach for your system"
echo
cmd_prev=
for cmd_option
do
# If the previous option needs an argument, assign it.
if test -n "$cmd_prev"; then
eval "$cmd_prev=\$cmd_option"
cmd_prev=
continue
fi
case "$cmd_option" in
-prefix | --prefix)
cmd_prev=prefix ;;
-prefix=* | --prefix=*)
prefix=`echo $cmd_option | cut -d = -f 2` ;;
-bindir | --bindir)
cmd_prev=bindir ;;
-bindir=* | --bindir=*)
bindir=`echo $cmd_option | cut -d = -f 2` ;;
-procmail | --procmail)
cmd_prev=LOCAL_MAILER ;;
-procmail=* | --procmail=*)
LOCAL_MAILER=`echo $cmd_option | cut -d = -f 2` ;;
-sendmail | --sendmail)
cmd_prev=MTA_COMMAND ;;
-sendmail=* | --sendmail=*)
MTA_COMMAND=`echo $cmd_option | cut -d = -f 2` ;;
-sysconfdir | --sysconfdir)
cmd_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=*)
sysconfdir=`echo $cmd_option | cut -d = -f 2` ;;
-*)
{
cat << EOF
The following switches can be used to override the defaults:
--prefix=path
Install everything under different root. e.g,
--prefix=\$HOME
--bindir=path
Set directory where binaries will be installed
--sysconfdir=path
Set directory where renattach.conf will be installed
--sendmail=path/filename
Explicitly specify sendmail-like MTA (e.g. /usr/sbin/sendmail)
--procmail=path/filename
Explicitly specify procmail-like mailer (e.g. /usr/bin/procmail)
EOF
exit 1
}
esac
done
echo "Binaries will be installed in"
echo " $prefix$bindir"
echo "renattach.conf will be installed in"
echo " $prefix$sysconfdir"
echo
if test -n "$MTA_COMMAND" ; then
echo "MTA (sendmail or equivalent) is"
echo " $MTA_COMMAND"
else
echo "Checking for MTA ($OUR_MTA)"
for mta_dir in \
/usr/bin/ \
/usr/sbin/ \
/usr/lib/ \
/usr/local/bin/ \
/usr/local/sbin/ \
/usr/local/lib/ \
; \
do
if test -x "$mta_dir$OUR_MTA" ; then
MTA_COMMAND=$mta_dir$OUR_MTA
break;
fi
done
if test -x "$MTA_COMMAND" ; then
echo " $MTA_COMMAND"
else
echo " Error: unable to find $OUR_MTA"
exit 1
fi
fi
if test -n "$LOCAL_MAILER" ; then
echo "Local mailer (procmail or equivalent) is"
echo " $LOCAL_MAILER"
else
echo
echo "Checking for local mailer ($OUR_LM)"
for lm_dir in \
/usr/bin/ \
/usr/sbin/ \
/usr/local/bin/ \
/usr/local/sbin/ \
; \
do
if test -x "$lm_dir$OUR_LM" ; then
LOCAL_MAILER=$lm_dir$OUR_LM
break;
fi
done
if test -x "$LOCAL_MAILER" ; then
echo " $LOCAL_MAILER"
else
echo " Error: unable to find $OUR_LM"
exit 1
fi
fi
grep -v "//" defs.base > defs.h
echo -e "#define MTA_COMMAND\t\"$MTA_COMMAND\"" >> defs.h
echo -e "#define LOCAL_MAILER\t\"$LOCAL_MAILER\"" >> defs.h
echo -e "#define CONF_FILE\t\"/etc/renattach.conf\"" >> defs.h
echo >> defs.h
echo "BINDIR=$prefix$bindir" > Makefile
echo "CONFDIR=$prefix$sysconfdir" >> Makefile
echo "CC=gcc" >> Makefile
echo -e "CFLAGS=-Wall -O2\n" >> Makefile
echo -e "renattach : renattach.o settings.o" >> Makefile
echo -e "\t\$(CC) \$(CFLAGS) -o renattach renattach.o settings.o\n" >> Makefile
echo "clean:" >> Makefile
echo -e "\trm -f renattach" >> Makefile
echo -e "\trm -f *.o\n" >> Makefile
echo "install: renattach" >> Makefile
echo -e "\t@if [ ! -r \$(BINDIR) ] ; then mkdir -p \$(BINDIR) ; fi" >> Makefile
echo -e "\t@if [ ! -r \$(CONFDIR) ] ; then mkdir -p \$(CONFDIR) ; fi" >> Makefile
echo -e "\t./install.sh renattach \$(BINDIR) -s -m 755" >> Makefile
echo -e "\t@if [ -r \$(CONFDIR)/renattach.conf ] ; \\" >> Makefile
echo -e "\t\tthen echo \"Not replacing existing .conf file\" ; \\" >> Makefile
echo -e "\t\telse ./install.sh renattach.conf \$(CONFDIR) -m 644 ; \\" >> Makefile
echo -e "\t\techo \"./install.sh renattach.conf \$(CONFDIR) -m 644\" ; fi\n" >> Makefile
echo "uninstall:" >> Makefile
echo -e "\trm -f \$(BINDIR)/renattach" >> Makefile
echo -e "\trm -i \$(CONFDIR)/renattach.conf\n" >> Makefile
echo
echo
echo "defs.h and Makefile have been created"
echo "Edit defs.h to tweak features, if you wish"
echo
echo "Now ready for 'make'"
echo
|