============
||
============
- 用于建立qmail用户和用户组的脚本(文件名:IDS) (改变权限:chmod 700 IDS)
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias alias
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails - 文件 /var/qmail/rc
#!/bin/sh
# Using stdout for logging
# Using control/defaultdelivery from qmail-local to deliver messages by default
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start "`cat /var/qmail/control/defaultdelivery`" - 文件 /var/qmail/bin/qmailctl
#!/bin/sh
# description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
case "$1" in
start)
echo "Starting qmail"
if svok /service/qmail-send ; then
svc -u /service/qmail-send /service/qmail-send/log
else
echo "qmail-send supervise not running"
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
else
echo "qmail-smtpd supervise not running"
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo "Stopping qmail..."
echo " qmail-smtpd"
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo " qmail-send"
svc -d /service/qmail-send /service/qmail-send/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
qmail-qstat
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /service/qmail-smtpd
;;
cont)
echo "Continuing qmail-send"
svc -c /service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /service/qmail-smtpd
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /service/qmail-send /service/qmail-send/log
echo "* Restarting qmail-smtpd."
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat <<HELP
stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
exit 0 - 文件 /var/qmail/supervise/qmail-send/run
#!/bin/sh
exec /var/qmail/rc - 文件 /var/qmail/supervise/qmail-send/log/run
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail - 文件 /var/qmail/supervise/qmail-smtpd/run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
- 文件 /var/qmail/supervise/qmail-smtpd/log/run
#!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd - 文件 inst_check
# Dave Sill, 2003-11-10
# http://lifewithqmail.org/inst_check
# set to n if you're not running a pop3 server, y if you are
CHECKPOP=n
QMHOME=/var/qmail
LBIN=/usr/local/bin
OK=1
if [ $# -eq 1 ]; then
if [ "$1" = "-v" ]; then
VERB=y
else
VERB=n
fi
fi
if [ ! -d $QMHOME ]; then
echo "! Couldn't find qmail's home directory, $QMHOME!"
else
if [ "$VERB" = y ]; then
echo "$QMHOME exists"
fi
for i in alias bin boot control doc man queue supervise users; do
if [ ! -d $QMHOME/$i ]; then
echo "! Couldn't find $QMHOME/$i!"
OK=0
elif [ "$VERB" = y ]; then
echo "$QMHOME/$i exists"
fi
done
if [ ! -f $QMHOME/rc ]; then
echo "! $QMHOME/rc is missing"
OK=0
elif [ ! -x $QMHOME/rc ]; then
echo "! $QMHOME/rc is not executable"
echo "...try: chmod 755 $QMHOME/rc"
OK=0
elif [ `head -1 $QMHOME/rc|cat -vet` != '#!/bin/sh$' ]; then
echo "! $QMHOME/rc has bad magic cookie"
echo "...try: dos2unix $QMHOME/rc"
OK=0
elif [ "$VERB" = y ]; then
echo "$QMHOME/rc is executable and has a valid magic cookie"
fi
fi
for i in alias qmaild qmaill qmailp qmailq qmailr qmails; do
grep "^$i:" /etc/passwd >/dev/null
if [ $? -ne 0 ]; then
echo "! Couldn't find $i user in /etc/passwd"
OK=0
elif [ "$VERB" = y ]; then
echo "$i user exists"
fi
done
for i in qmail nofiles; do
grep "^$i:" /etc/group >/dev/null
if [ $? -ne 0 ]; then
echo "! Couldn't find $i group in /etc/group"
OK=0
elif [ "$VERB" = y ]; then
echo "$i group exists"
fi
done
for i in tcprules tcpserver; do
if [ ! -x $LBIN/$i ]; then
echo "! Couldn't find $LBIN/$i from ucspi-tcp"
OK=0
elif [ "$VERB" = y ]; then
echo "$i from ucspi-tcp is installed"
fi
done
for i in multilog softlimit setuidgid supervise svok svscan tai64nlocal; do
if [ ! -x $LBIN/$i ]; then
echo "! Couldn't find $LBIN/$i from daemontools"
OK=0
elif [ "$VERB" = y ]; then
echo "$i from daemontools is installed"
fi
done
if [ ! -d /service ]; then
echo "! /service directory is missing"
OK=0
elif [ "$VERB" = y ]; then
echo "/service directory exists"
fi
if [ -f /etc/inittab ]; then
grep "^SV" /etc/inittab >/dev/null
if [ $? -ne 0 ]; then
echo "! Couldn't find SV entry in inittab"
OK=0
elif [ "$VERB" = y ]; then
echo "svscan /service is configured to run via /etc/inittab"
fi
PS="ps -ef"
else
grep "svscanboot" /etc/rc.local >/dev/null
if [ $? -ne 0 ]; then
echo "! Couldn't find 'csh -cf '/command/svscanboot &' in /etc/rc.local"
OK=0
elif [ "$VERB" = y ]; then
echo "/command/svscanboot is configured to run via /etc/rc.local"
fi
PS="ps -waux"
fi
SVRUN=`$PS | grep "svscan /service" | grep -v grep`
if [ -z "$SVRUN" ]; then
echo "'! svscan /service' doesn't seem to be running"
OK=0
elif [ "$VERB" = y ]; then
echo "svscan /service is running"
fi
if [ ! -f $QMHOME/control/defaultdelivery ]; then
echo "! Couldn't find $QMHOME/control/defaultdelivery"
OK=0
elif [ ! -s $QMHOME/control/defaultdelivery ]; then
echo "! $QMHOME/control/defaultdelivery is empty"
OK=0
elif [ "$VERB" = y ]; then
echo "$QMHOME/control/defaultdelivery looks OK"
fi
if [ ! -f $QMHOME/bin/qmailctl ]; then
echo "! $QMHOME/bin/qmailctl is missing"
OK=0
elif [ ! -s $QMHOME/bin/qmailctl ]; then
echo "! $QMHOME/bin/qmailctl is empty"
OK=0
elif [ `head -1 $QMHOME/bin/qmailctl|cat -vet` != '#!/bin/sh$' ]; then
echo "! $QMHOME/bin/qmailctl has bad magic cookie"
echo "...try: dos2unix $QMHOME/bin/qmailctl"
OK=0
elif [ ! -x $QMHOME/bin/qmailctl ]; then
echo "! $QMHOME/bin/qmailctl is not executable"
echo "...try: chmod 755 $QMHOME/bin/qmailctl"
OK=0
elif [ "$VERB" = y ]; then
echo "$QMHOME/bin/qmailctl looks OK"
fi
if [ ! -L /usr/bin/qmailctl ]; then
echo "! /usr/bin/qmailctl is missing"
echo "...try: ln -s $QMHOME/bin/qmailctl /usr/bin"
OK=0
elif [ "$VERB" = y ]; then
echo "/usr/bin/qmailctl exists"
fi
SVCDIRS="qmail-send qmail-send/log qmail-smtpd qmail-smtpd/log"
if [ "$CHECKPOP" = "y" ]; then
SVCDIRS="$SVCDIRS qmail-pop3d qmail-pop3d/log"
fi
for i in $SVCDIRS; do
if [ ! -f $QMHOME/supervise/$i/run ]; then
echo "! $QMHOME/supervise/$i/run file is missing"
OK=0
elif [ `head -1 $QMHOME/supervise/$i/run|cat -vet` != '#!/bin/sh$' ]; then
echo "! $QMHOME/supervise/$i/run has bad magic cookie"
echo "...try: dos2unix $QMHOME/supervise/$i/run"
OK=0
elif [ ! -x $QMHOME/supervise/$i/run ]; then
echo "! $QMHOME/supervise/$i/run file is not executable"
OK=0
elif [ "$VERB" = y ]; then
echo "$QMHOME/supervise/$i/run looks OK"
fi
done
if [ ! -f $QMHOME/control/concurrencyincoming ]; then
echo "! $QMHOME/control/concurrencyincoming is missing"
echo "...try: echo 20 >$QMHOME/control/concurrencyincoming"
OK=0
elif [ "$VERB" = y ]; then
echo "$QMHOME/control/concurrencyincoming looks OK"
fi
LOGDIRS="/var/log/qmail /var/log/qmail/smtpd"
if [ "$CHECKPOP" = "y" ]; then
LOGDIRS="$LOGDIRS /var/log/qmail/pop3d"
fi
for i in $LOGDIRS; do
if [ ! -d $i ]; then
echo "! $i is missing"
echo "...try: mkdir -p $i"
OK=0
elif [ "`ls -ld $i|awk '{print $3}'`" != "qmaill" ]; then
echo "! $i has wrong owner, should be qmaill"
echo "...try: chown qmaill $i"
OK=0
elif [ "`ls -ld $i|awk '{print $1}'`" != "drwxr-xr-x" ]; then
echo "! $i has wrong mode, should be 755"
echo "...try: chmod 755 $i"
OK=0
elif [ "$VERB" = y ]; then
echo "$i looks OK"
fi
done
SVCLINKS="/service/qmail-send /service/qmail-smtpd"
if [ "$CHECKPOP" = "y" ]; then
SVCLINKS="$SVCLINKS /service/qmail-pop3d"
fi
for i in $SVCLINKS; do
if [ ! -L $i ]; then
echo "! $i is missing"
echo "...try: ln -s $QMHOME$i $i"
OK=0
elif [ "$VERB" = y ]; then
echo "$i exists"
fi
done
if [ ! -f /etc/tcp.smtp ]; then
echo "! /etc/tcp.smtp is missing"
echo "...try: echo '127.:allow,RELAYCLIENT=\"\"' >>/etc/tcp.smtp"
OK=0
elif [ "$VERB" = y ]; then
echo "/etc/tcp.smtp exists"
fi
if [ ! -f /etc/tcp.smtp.cdb ]; then
echo "! /etc/tcp.smtp.cdb is missing"
echo "...try: $QMHOME/bin/qmailctl cdb"
OK=0
elif [ "$VERB" = y ]; then
echo "/etc/tcp.smtp.cdb exists"
fi
AHOME=`grep "^alias:" /etc/passwd | awk -F: '{print $6}'`
if [ -z "$AHOME" ]; then
echo "! Couldn't find user alias's home directory"
OK=0
else
for i in root postmaster mailer-daemon; do
if [ ! -f $AHOME/.qmail-$i ]; then
echo "! Alias for $i is missing"
echo "...try: echo me >$AHOME/.qmail-$i"
OK=0
elif [ "$VERB" = y ]; then
echo "$i alias exists"
fi
done
fi
if netstat -a | grep smtp | grep -i listen >/dev/null; then
if $PS | grep sendmail | grep -v grep >/dev/null; then
echo "! Sendmail is still running"
echo "...try: $RCDIR/init.d/sendmail stop"
OK=0
elif $LBIN/svok /service/qmail-smtpd; then
if [ "$VERB" = y ]; then
echo "/service/qmail-smtpd is running"
fi
else
echo "! Something is listening on port 25 (not tcpserver/qmail-smtpd)"
echo "...try: disabling current MTA"
OK=0
fi
fi
if [ "$CHECKPOP" = "y" ]; then
if netstat -a | grep pop | grep -i listen >/dev/null; then
if $LBIN/svok /service/qmail-pop3d; then
if [ "$VERB" = y ]; then
echo "/service/qmail-pop3d is running"
fi
else
echo "! Something is listening on port 110 (not tcpserver/qmail-pop3d)"
echo "...try: disabling other POP server"
OK=0
fi
fi
fi
for i in /usr/lib/sendmail /usr/sbin/sendmail; do
if [ -f $i -a ! -L $i ]; then
echo "! $i is a file, should be a link"
echo "...try: uninstalling current MTA or: mv $i $i.old; ln -s $QMHOME/bin/sendmail $i"
OK=0
elif [ ! -f $i ];then
echo "! $i is missing"
echo "...try: ln -s $QMHOME/bin/sendmail $i"
OK=0
elif [ "$VERB" = y ]; then
echo "$i exists"
fi
done
if [ $OK -eq 1 ]; then
echo "Congratulations, your LWQ installation looks good!"
elif [ "$VERB" = y ]; then
echo "! Potential problems were found with your LWQ installation"
fi - 文件 /var/qmail/supervise/qmail-pop3d/run
(注:2000000这个比较小,最好是设置大些,以免出现不能载入的问题)
#!/bin/sh
LOCAL=`head -1 /var/qmail/control/me`
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -H -l 0 0 110 /var/qmail/bin/qmail-popup \
"$LOCAL" /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir 2>&1 - 文件 /var/qmail/supervise/qmail-pop3d/log/run
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t \
/var/log/qmail/pop3d - 添加了 pop3 部分的完整的 qmailctl 文件
#!/bin/sh
# Description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
case "$1" in
start)
echo "Starting qmail"
if svok /service/qmail-send ; then
svc -u /service/qmail-send /service/qmail-send/log
else
echo "qmail-send supervise not running"
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
else
echo "qmail-smtpd supervise not running"
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
if svok /service/qmail-pop3d ; then
svc -u /service/qmail-pop3d /service/qmail-pop3d/log
else
echo qmail-pop3d supervise not running
fi
;;
stop)
echo "Stopping qmail..."
echo " qmail-smtpd"
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo " qmail-send"
svc -d /service/qmail-send /service/qmail-send/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
echo " qmail-pop3d"
svc -d /service/qmail-pop3d /service/qmail-pop3d/log
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
qmail-qstat
svstat /service/qmail-pop3d
svstat /service/qmail-pop3d/log
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /service/qmail-smtpd
echo "Pausing qmail-pop3d"
svc -p /service/qmail-pop3d
;;
cont)
echo "Continuing qmail-send"
svc -c /service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /service/qmail-smtpd
echo "Continuing qmail-pop3d"
svc -c /service/qmail-pop3d
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /service/qmail-send /service/qmail-send/log
echo "* Restarting qmail-smtpd."
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Restarting qmail-pop3d."
svc -t /service/qmail-pop3d /service/qmail-pop3d/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat <<HELP
stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
exit 0 - 文件 ~vpopmail/domains/.quotawarn.msg
From: YourCompany Postmaster <postmaster@ YourCompany.com>
Reply-To: postmaster@ YourCompany.com
To: YourCompany User:;
Subject: Mail quota warning
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Your mailbox on the server is now more than 90% full.
So that you can continue to receive mail,
you need to remove some messages from your mailbox.
If you require assistance with this,
please contact our support department :
Email : xxx @ xxx.com
Telphone: xxx xxx xxx - 文件 /var/qmail/supervise/qmail-pop3d/run (安装了vpopmail后的文件)
(注:如果内存够大,这个-m 的值还是设大些的好。这里设定为10M)
#!/bin/sh
LOCAL=`head -1 /var/qmail/control/me`
exec /usr/local/bin/softlimit -m 10000000 \
/usr/local/bin/tcpserver -v -R -H -l 0 0 pop3 /var/qmail/bin/qmail-popup \
"$LOCAL" ~vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1 - 文件 /var/qmail/supervise/qmail-smtpd/run (安装了vpopmail后的文件)
(注:如果内存够大,这个-m 的值还是设大些的好。这里设定为10M)
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
VPOPMAILUID='id -u vpopmail'
VCHKPWGID='id -g vchkpw'
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 20000000 \
/usr/local/bin/tcpserver -H -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u"$VPOPMAILUID" -g "$VCHKPWGID" 0 smtp /var/qmail/bin/qmail-smtpd "$LOCAL" ~vpopmail/bin/vchkpw /bin/true 2>&1