このWebサイト ひつじ帳 は、管理者がWEB関連の技術をまとめた備忘録サイトです。 Linux,CentOS,PHP,MySQL,Blogger,JavaScript,CSS について記録しています。

CentOS-5/qmail/起動スクリプト設定例

[ qmail ]

起動スクリプト ファイル内容 /etc/rc.d/init.d/qmail

qmail + vpopmail / SMTP認証 用


#!/bin/bash
#
# qmail: /var/qmail
#
# chkconfig: 2345 80 30
# description: qmail start/stop script

# Source function library.
. /etc/rc.d/init.d/functions

PATH=/var/qmail/bin:/usr/local/bin:/bin:/usr/bin

[ -f /var/qmail/rc ] || exit 0

start() {
 # Start daemons.
 if [ -z $(/sbin/pidof qmail-send) ];  then
  echo -n "Starting qmail"

  # qmail
   csh -cf '/var/qmail/rc &' 2>&1 > /dev/null

  # SMTP
  tcpserver -qv -l0 -HR -u `id -u vpopmail` -g `id -g vpopmail` 0 smtp \
  qmail-smtpd `hostname` 2>&1 | splogger smtp 3 &

  # SMTP OP25B Submission
  tcpserver -qv -l0 -HR -u `id -u vpopmail` -g `id -g vpopmail` -x /home/vpopmail/etc/tcp.smtp.cdb 0 submission \
  qmail-smtpd `hostname` /home/vpopmail/bin/vchkpw /bin/true 2>&1 | splogger smtp 3 &

  #----- ▼ SMTPS導入の場合 -----#
  # SMTPS
  tcpserver-ssl -qvs -l0 -HR -u `id -u vpopmail` -g `id -g vpopmail` -n /var/qmail/cert.pem -x /home/vpopmail/etc/tcp.smtp.cdb 0 smtps \
  qmail-smtpd `hostname` /home/vpopmail/bin/vchkpw /bin/true 2>&1 | splogger smtps 3 &
  #----- ▲ SMTPS導入の場合 -----#

  # POP3
  tcpserver -qvHR -u `id -u vpopmail` -g `id -g vpopmail` 0 pop3 \
  qmail-popup `hostname` /home/vpopmail/bin/vchkpw qmail-pop3d Maildir 2>&1 | splogger pop3 3 &

  #----- ▼ POP3S導入の場合 -----#
  # POP3S
  tcpserver-ssl -qvsHR -u `id -u vpopmail` -g `id -g vpopmail` -n /var/qmail/cert.pem 0 pop3s \
  qmail-popup `hostname` /home/vpopmail/bin/vchkpw qmail-pop3d Maildir 2>&1 | splogger pop3s 3 &
  #----- ▲ POP3S導入の場合 -----#

  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && touch /var/lock/subsys/qmail
  return $RETVAL
 else
  echo "qmail is already started"
 fi
}

stop() {
 # Stop daemons.
 if [ ! -z $(/sbin/pidof qmail-send) ];  then
  echo -n "Shutting down qmail"
  /bin/kill $(/sbin/pidof tcpserver)
  /bin/kill $(/sbin/pidof qmail-send)
  until [ -z $(/sbin/pidof qmail-send) ] && [ -z $(/sbin/pidof tcpserver) ]; do :; done
  echo
  rm -f /var/lock/subsys/qmail
 else
  echo "qmail is not running"
 fi
}

case "$1" in
 start)
  start
  ;;
 stop)
  stop
  ;;
 restart)
  stop
  start
  ;;
 status)
  if [ ! -z $(/sbin/pidof qmail-send) ] ;  then
   echo -n "qamil (pid"
   echo -n " `/sbin/pidof qmail-send`"
   echo -n " `/sbin/pidof tcpserver`"
   echo ") is running..."
  else
   echo "qmail is stoped"
  fi
   ;;
 *)
  echo "Usage: qmail {start|stop|restart|status}"
  exit 1
esac

exit 0

qmail + vpopmail / POP Before SMTP 用


#!/bin/bash
#
# qmail: /var/qmail
#
# chkconfig: 2345 80 30
# description: qmail start/stop script

# Source function library.
. /etc/rc.d/init.d/functions

PATH=/var/qmail/bin:/usr/local/bin:/bin:/usr/bin

[ -f /var/qmail/rc ] || exit 0

start() {
 # Start daemons.
 if [ -z $(/sbin/pidof qmail-send) ];  then
  echo -n "Starting qmail"

  # qmail
  csh -cf '/var/qmail/rc &' 2>&1 > /dev/null

  # SMTP
  tcpserver -HRlv `hostname` -v -x /home/vpopmail/etc/tcp.smtp.cdb -u `id -u vpopmail` -g `id -g vpopmail` 0 smtp \
  qmail-smtpd 2>&1 | splogger smtp 3 &

  # SMTP OP25B Submission
  tcpserver -HRlv `hostname` -v -x /home/vpopmail/etc/tcp.smtp.cdb -u `id -u qmaild` -g `id -g qmaild` 0 submission \
  qmail-smtpd 2>&1 | splogger smtp 3 &

  # POP3
  tcpserver -HRlv `hostname` -v 0 pop3 qmail-popup `hostname` /home/vpopmail/bin/vchkpw \
  qmail-pop3d Maildir 2>&1 | splogger pop3 3 &

   RETVAL=$?
  echo
  [ $RETVAL = 0 ] && touch /var/lock/subsys/qmail
  return $RETVAL
 else
  echo "qmail is already started"
 fi
}

stop() {
 # Stop daemons.
 if [ ! -z $(/sbin/pidof qmail-send) ];  then
  echo -n "Shutting down qmail"
  /bin/kill $(/sbin/pidof tcpserver)
  /bin/kill $(/sbin/pidof qmail-send)
  until [ -z $(/sbin/pidof qmail-send) ] && [ -z $(/sbin/pidof tcpserver) ]; do :; done
  echo
  rm -f /var/lock/subsys/qmail
 else
  echo "qmail is not running"
 fi
}

case "$1" in
 start)
  start
  ;;
 stop)
  stop
  ;;
 restart)
  stop
  start
  ;;
 status)
  if [ ! -z $(/sbin/pidof qmail-send) ] ;  then
   echo -n "qamil (pid"
   echo -n " `/sbin/pidof qmail-send`"
   echo -n " `/sbin/pidof tcpserver`"
   echo ") is running..."
  else
   echo "qmail is stoped"
  fi
   ;;
 *)
  echo "Usage: qmail {start|stop|restart|status}"
  exit 1
esac

exit 0

qmail のみインストール / POP Before SMTP 用


#!/bin/bash
#
# qmail: /var/qmail
#
# chkconfig: 2345 80 30
# description: qmail start/stop script

# Source function library.
. /etc/rc.d/init.d/functions

PATH=/var/qmail/bin:/usr/local/bin:/bin:/usr/bin

[ -f /var/qmail/rc ] || exit 0

start() {
 # Start daemons.
 if [ -z $(/sbin/pidof qmail-send) ];  then
  echo -n "Starting qmail"

  # qmail
  csh -cf '/var/qmail/rc &' 2>&1 > /dev/null

  # SMTP
  tcpserver -HRlv -u `id -u qmaild` -g `id -g qmaild` 0 smtp \
  qmail-smtpd `hostname` /bin/checkpassword /bin/true 2>&1 | splogger smtp 3 &

  # SMTP OP25B Submission
  envdir /etc/relay-ctrl relay-ctrl-chdir \
  tcpserver -HRlv -u `id -u qmaild` -g `id -g qmaild` -x /etc/tcp.smtp.cdb 0 submission \
  relay-ctrl-check qmail-smtpd `hostname` /bin/checkpassword /bin/true 2>&1 | splogger smtp 3 &

  # POP3
  envdir /etc/relay-ctrl relay-ctrl-chdir \
  tcpserver -HRlv -u `id -u qmaild` -g `id -g qmaild` 0 pop3 qmail-popup `hostname` /bin/checkpassword \
  relay-ctrl-allow qmail-pop3d Maildir 2>&1 | splogger pop3 3 &

  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && touch /var/lock/subsys/qmail
  return $RETVAL
 else
  echo "qmail is already started"
 fi
}

stop() {
 # Stop daemons.
 if [ ! -z $(/sbin/pidof qmail-send) ];  then
  echo -n "Shutting down qmail"
  /bin/kill $(/sbin/pidof tcpserver)
  /bin/kill $(/sbin/pidof qmail-send)
  until [ -z $(/sbin/pidof qmail-send) ] && [ -z $(/sbin/pidof tcpserver) ]; do :; done
  echo
  rm -f /var/lock/subsys/qmail
 else
  echo "qmail is not running"
 fi
}

case "$1" in
 start)
  start
  ;;
 stop)
  stop
  ;;
 restart)
  stop
  start
  ;;
 status)
  if [ ! -z $(/sbin/pidof qmail-send) ] ;  then
   echo -n "qamil (pid"
   echo -n " `/sbin/pidof qmail-send`"
   echo -n " `/sbin/pidof tcpserver`"
   echo ") is running..."
  else
   echo "qmail is stoped"
  fi
   ;;
 *)
  echo "Usage: qmail {start|stop|restart|status}"
  exit 1
esac

exit 0

0 件のコメント:

人気記事

アーカイブ

このブログを検索