0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

postfixをマルチインスタンスにした時のsystemdのサービスファイルを作成した

Posted at

postfixをマルチインスタンスで使う時の、systemdのサービスファイルをサービスファイルを作成してみた。元々用意されているのはシングルインスタンスで起動するものなので、ザクっと置き換えよう。

プライマリのインスタンスは、デフォルトの/etc/postfixを使うものとして、セカンダリは/etc/postfix-2へ作成されているものとする。マルチインスタンス化については、ググって欲しい。

元々インストールされている/usr/lib/systemd/system/postfix.serviceはシングルインスタンス用なので、以下に入れ替える。また、セカンダリ用のは別途新規に作成する。

/usr/lib/systemd/system/posftix.service
[Unit]
Description=Postfix Mail Transport Agent(Primary)
After=syslog.target network.target
Conflicts=sendmail.service exim.service

[Service]
Type=forking
PIDFile=/var/spool/postfix/pid/master.pid
EnvironmentFile=-/etc/sysconfig/network
ExecStartPre=-/usr/libexec/postfix/aliasesdb
ExecStartPre=-/usr/libexec/postfix/chroot-update
ExecStart=/sbin/postmulti -i /etc/postfix -p start
ExecReload=/sbin/postmulti -i /etc/postfix -p reload
ExecStop=/sbin/postmulti -i /etc/postfix -p stop
Restart=always

[Install]
WantedBy=multi-user.target
/usr/lib/systemd/system/postfix-2.service
[Unit]
Description=Postfix Mail Transport Agent(Secondary)
After=syslog.target network.target
Conflicts=sendmail.service exim.service

[Service]
Type=forking
PIDFile=/var/spool/postfix-2/pid/master.pid
EnvironmentFile=-/etc/sysconfig/network
ExecStartPre=-/usr/libexec/postfix/aliasesdb
ExecStartPre=-/usr/libexec/postfix/chroot-update
ExecStart=/sbin/postmulti -i /etc/postfix-2 -p start
ExecReload=/sbin/postmulti -i /etc/postfix-2 -p reload
ExecStop=/sbin/postmulti -i /etc/postfix-2 -p stop
Restart=always

[Install]
WantedBy=multi-user.target

後は、以下のコマンドで有効にして起動・停止ができる。

# systemctl enable postfix
# systemctl enable postfix-2

# systemctl start postfix
# systemctl start postfix-2

# systemctl status postfix
# systemctl status postfix-2

# systemctl stop postfix
# systemctl stop postfix-2

てな感じですかね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?