2007.11.19
Dovecot の init 書いてみた。
昨日のリプレースで 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



Comment & Trackback
Comment