起動・停止方法のメモ

今日はCourier Mail Serverの起動・停止方法についてのメモです。

起動


pop3及びimapは起動スクリプトを実行すれば起動します。

# /etc/init.d/courier start
Starting Courier mail server: courierfilter courierldapaliasd webmail courierd pop3d pop3d-ssl imapd imapd-ssl
# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 :::993                      :::*                        LISTEN      
tcp        0      0 :::995                      :::*                        LISTEN      
tcp        0      0 :::110                      :::*                        LISTEN      
tcp        0      0 :::143                      :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      


全部起動するかと思ったのですが、smtpを起動させたい場合は、これだけではダメでした。
「/usr/lib/courier/sbin」以下にバイナリが存在するので、こいつに引数を与えます。

# /usr/lib/courier/sbin/esmtpd start
# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 :::993                      :::*                        LISTEN      
tcp        0      0 :::995                      :::*                        LISTEN      
tcp        0      0 :::110                      :::*                        LISTEN      
tcp        0      0 :::143                      :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::25                       :::*                        LISTEN      


以下を実行すると587番ポート(サブミッションポート)での待ち受けを開始しました。
詳細は試していないのでまた今度。

# /usr/lib/courier/sbin/esmtpd-msa start
# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 :::993                      :::*                        LISTEN      
tcp        0      0 :::995                      :::*                        LISTEN      
tcp        0      0 :::587                      :::*                        LISTEN      
tcp        0      0 :::110                      :::*                        LISTEN      
tcp        0      0 :::143                      :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::25                       :::*                        LISTEN      

停止


停止する場合は、起動スクリプトに引数「stop」だけでOKです。
なぜこういう動きをするのでしょう・・・?

# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 :::993                      :::*                        LISTEN      
tcp        0      0 :::995                      :::*                        LISTEN      
tcp        0      0 :::587                      :::*                        LISTEN      
tcp        0      0 :::110                      :::*                        LISTEN      
tcp        0      0 :::143                      :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::25                       :::*                        LISTEN      
# /etc/init.d/courier stop
Stopping Courier mail server: webmlmd imapd imapd-ssl esmtpd-ssl esmtpd-msa esmtpd pop3d pop3d-ssl courierd webmail courierldapaliasd courierfilter
# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 :::22                       :::*                        LISTEN      

スクリプトを調査


ということで、「/etc/init.d/courier」を読んでみました。

90		. ${sysconfdir}/esmtpd
91		case x$ESMTPDSTART in
92		x[yY]*)
93	
94			${sbindir}/esmtpd start
95			echo -n " esmtpd"
96			;;
97		esac
98	
99		. ${sysconfdir}/esmtpd-msa
100		case x$ESMTPDSTART in
101		x[yY]*)
102	
103			${sbindir}/esmtpd-msa start
104			echo -n " esmtpd-msa"
105			;;
106		esac


起動させるかどうかは、どうやら環境変数が関係するようです。
それでは、と「/etc/courier/esmtpd」「/etc/courier/esmtpd-msa」を見てみる事に。

# vi /etc/courier/esmtpd
457 # The default setting is going to be NO, until Courier is shipped by default
458 # with enough platforms so that people get annoyed with having to flip it to
459 # YES every time.
460 
461 ESMTPDSTART=NO

# vi /etc/courier/esmtpd-msa
113 # The default setting is going to be NO, until Courier is shipped by default
114 # with enough platforms so that people get annoyed with having to flip it to
115 # YES every time.
116 
117 ESMTPDSTART=NO


両方とも「ESMTPDSTART=NO」を「ESMTPDSTART=YES」に変更して、
再度起動スクリプトを実行すると、今度は自動起動するようになりました。

# /etc/init.d/courier start
Starting Courier mail server: courierfilter courierldapaliasd webmail courierd generating-ESMTP-SSL-certificate... esmtpd esmtpd-msa pop3d pop3d-ssl imapd imapd-ssl
# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 :::993                      :::*                        LISTEN      
tcp        0      0 :::995                      :::*                        LISTEN      
tcp        0      0 :::587                      :::*                        LISTEN      
tcp        0      0 :::110                      :::*                        LISTEN      
tcp        0      0 :::143                      :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::25                       :::*                        LISTEN


今日はこんなところで。