昨日のリプレースで MRA が Dovecot になった訳だが、ソースからコンパイルしているので
OS 起動時の自動実行プログラムが無い状態。
これだといちいち起動させるのが面倒だし、通常の運用面でも Restart かけるときに面倒だ。

で、init を書いておいた。

とはいっても既に init ファイルのひな形は昔 BIND のやつ書いたときには出来上がっていたので
これを使ってパラメータとメッセージを書き換えただけ。

参考にするのであれば PID とバイナリの位置、conf ファイルを自分の環境に合わせること。

#!/bin/sh
#
# Dovecot init scripts
#                                                                    2007/11/19

# Set variables.
PID="/var/run/dovecot/master.pid"
BIN="/usr/local/sbin/dovecot"
CNF="/usr/local/etc/dovecot.conf"

# Functions
start() {
        printf "Dovecot Start: "
        if [ -f ${PID} ]; then
                printf "Failed. maybe already running.\n"
        else
                ${BIN} -c ${CNF}
                printf "Success\n"
        fi
}

stop() {
        printf "Dovecot Stop: "
        if [ -f ${PID} ]; then
                kill -TERM `cat ${PID}`
                printf "Stopped\n"
                [ -f ${PID} ] && rm -f ${PID}
        else
                printf "Dovecot is not running.\n"
                exit 1
        fi
}

restart() {
        printf "Dovecot Restart: "
        if [ -f ${PID} ]; then
                kill -HUP `cat ${PID}`
                printf "Success\n"
        else
                printf "Dovecot is not running.\n"
                exit 1
        fi
}

status() {
        if [ -f ${PID} ]; then
                printf "Dovecot available.\n"
        else
                printf "Dovecot is not available.\n"
        fi
}

# Main
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                restart
                ;;
        status)
                status
                ;;
        *)
                printf "Usage: $0 {start|stop|restart|status}\n"
                exit 1
esac

exit $?

(c) BuCCi

Related posts:

  1. named の init 作成
  2. 新サーバー構築 其の二 MySQL
  3. VirtualMailBox のユーザー追加スクリプト
  4. 超簡易プロビジョニングスクリプトを書いてみた。
  5. 新サーバー構築 其の一 BIND

 返信する


*

以下のHTML タグと属性が利用できます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt=""> <pre lang="" line="" escaped="" highlight="">

   
59 queries. 0.310 seconds.