#!/bin/sh
# qmail installation in RedHat9 shrike
# creat by vegalou@ms39.hinet.net 2003/5/22 13:35
# tar zxvf qmail-1.03a.tar.gz
# cd rh9
chmod 755 *
./adduser.sh
##### qmail setup
tar xzvf qmail-1.03a.tar.gz
cd qmail-1.03
make setup check
echo $HOSTNAME /var/qmail/control/me
echo $HOSTNAME /var/qmail/control/defaulthost
echo $HOSTNAME /var/qmail/control/defaultdomain
touch /var/qmail/control/concurrencyincoming
# ./config
# Sorry, I couldn't find your host's canonical name in DNS.
# You will have to set up control/me yourself.
cd ~alias; touch .qmail-postmaster .qmail-mailer-daemon .qmail-root;
chmod 644 ~alias/.qmail*
echo 'admin' ~alias/.qmail-mailer-daemon;echo 'admin' ~alias/.qmail-postmaster;echo 'admin' ~alias/.qmail-root
cp /var/qmail/boot/home /var/qmail/rc
cd -
cd ..
cp -f mail_rc /var/qmail/rc
##### ucspi-tcp
tar zxvf ucspi-tcp-0.88a.tar.gz
cd ucspi-tcp-0.88
make;make setup check
cd ..
##### checkpassword
tar zxvf checkpassword-0.90a.tar.gz
cd checkpassword-0.90
make;make setup check
chmod og-rx /bin/checkpassword
cd ..
##### daemontools
tar zxvf daemontools-0.76a.tar.gz
cd daemontools-0.76
package/install
cd ..
##### daemontools and create control directories.
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
chmod +t /var/qmail/supervise/qmail-send
chmod +t /var/qmail/supervise/qmail-smtpd
chmod +t /var/qmail/supervise/qmail-pop3d
mkdir -p /var/log/qmail/qmail-send
mkdir -p /var/log/qmail/qmail-smtpd
chown -R qmaill /var/log/qmail
##### 6 run files in supervise dirs
cp run-pop3d /var/qmail/supervise/qmail-pop3d/run
cp run-pop3d-log /var/qmail/supervise/qmail-pop3d/log/run
cp run-send /var/qmail/supervise/qmail-send/run
cp run-send-log /var/qmail/supervise/qmail-send/log/run
cp run-smtpd /var/qmail/supervise/qmail-smtpd/run
cp run-smtpd-log /var/qmail/supervise/qmail-smtpd/log/run
##### [SMTP rules]
echo '127.0.0.1:allow,RELAYCLIENT=""' /etc/tcp.smtp
echo ":allow" /etc/tcp.smtp
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp
##### replace sendmail
service sendmail stop
mv /usr/lib/sendmail /usr/lib/sendmail.old
mv /usr/sbin/sendmail /usr/sbin/sendmail.old
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
# mv /usr/sbin/newaliases /usr/sbin/newaliases.old
# ln -s /var/qmail/bin/newaliases /usr/sbin/newaliases
ln -s /var/qmail/supervise/* /service/
### /etc/inittab
echo "" /etc/inittab
echo "SV:123456:respawn:env - PATH=/usr/local/bin:/usr/sbin:/usr/bin:/bin svscan /service" /etc/inittab
##### vpopmail setup
echo ":allow" ~vpopmail/etc/tcp.smtp
tar zxvf vpopmail-5.3.20.tar.gz
cd vpopmail-5.3.20
./configure --enable-roaming-users=y --enable-default-domain=$HOSTNAME --enable-passwd=n
make;make install-strip
# (?) how append crontab
cd ..
##### ezmlm
rpm -ivh ezmlm-idx-std-0.53.400-10.i386.rpm
##### autorespond
tar zxvf autorespond-2.0.2.tar.gz
cd autorespond-2.0.2
gcc -Wall -o autorespond autorespond.c
cp autorespond /usr/local/bin/autorespond
cd ..
##### qmailadmin
tar zxvf qmailadmin-1.0.6.tar.gz
cd qmailadmin-1.0.6
./configure;make;make install-strip
cd ..
##### init start
cp init_qmail /etc/rc.d/init.d/qmail
ln -s /etc/rc.d/init.d/qmail /etc/rc.d/rc3.d/S38qmail
service qmail restart
cp init_svscan /etc/rc.d/init.d/svscan
ln -s /etc/rc.d/init.d/svscan /etc/rc.d/rc3.d/S88svscan
service svscan restart
service qmail restart
echo "remember ntsysv to stop sendmail!"
echo "40 * * * * /home/vpopmail/bin/clearopensmtp /dev/null 2&1 &"