Archive for the 'postfix' Category

Linux:ソースからインストール&パッケージ作成

checkinstallなるものでソースからインストールしつつパッケージを作成できるらしいので試してみた。

まずはcheckinstallをインストールする。

wget http://asic-linux.com.mx/~izto/checkinstall/files/rpm/checkinstall-1.6.1-1.i386.rpm
rpm -ihv checkinstall-1.6.1

どこに入ったかわからなくなったので・・・^^;
rpm -ql checkinstall

どうやら/usr/local/sbin/checkinstall

-h でヘルプ表示
/usr/local/sbin/checkinstall -h

checkinstall 1.6.1, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.

Usage: checkinstall [options] [command [command arguments]]
Options:
*Package type selection*
-t,--type= Choose packaging system
-S Build a Slackware package
-R Build a RPM package
-D Build a Debian package
*Install options*
--install= Toggle created package installation
--fstrans= Enable/disable the filesystem translation code
*Scripting options*
-y, --default Accept default answers to all questions
--pkgname= Set name
--pkgversion= Set version
-A, --arch, --pkgarch= Set architecture
--pkgrelease= Set release
--pkglicense= Set license
--pkggroup= Set software group
--pkgsource= Set source location
--pkgaltsource= Set alternate source location
--pakdir= The new package will be saved here
--maintainer= The package maintainer (.deb)
--provides= Features provided by this package (.rpm)
--requires= Features required by this package
--rpmflags= Pass this flags to the rpm installer
--rpmi Use the -i flag for rpm when installing a .rpm
--rpmu Use the -U flag for rpm when installing a .rpm
--dpkgflags= Pass this flags to the dpkg installer
--spec= .spec file location
--nodoc Do not include documentation files

*Info display options*

-d<0|1|2> Set debug level
-si Run an interactive install command
--showinstall= Toggle interactive install command
-ss Run an interactive Slackware installation script
--showslack= Toggle interactive Slackware installation script

*Package tuning options*

--autodoinst= Toggle the creation of a doinst.sh script
--strip= Strip any ELF binaries found inside the package
--stripso= Strip any ELF binary libraries (.so files)
--addso= Search for any shared libs and add
them to /etc/ld.so.conf
--reset-uids= Reset perms for all files/dirs to 755 and
the owner/group for all dirs to root.root
--gzman= Compress any man pages found inside the package
--docdir= Where to put documentation files
--umask= Set the umask value
--exclude= Exclude these files/directories from the package
--include= Force the inclusion in the package of the
files/dirs listed in “listfile”
--inspect Inspect the package” file list
--review-spec Review the spec file before creating a .rpm
--review-control Review the control file before creating a .deb
--newslack Use the new (8.1+) Slackware description format
(“--newslack” implies “-S”)
--with-tar=/path/to/tar Manually set the path to the tar binary
in this system

*Cleanup options*

--deldoc= Delete doc-pak upon termination
--deldesc= Delete description-pak upon termination
--delspec= Delete spec file upon termination
--bk Backup any overwritten files
--backup= Toggle backup

*About CheckInstall*

--help, -h Show this message
--copyright Show Copyright information
--version Show version information

RPMは-Rか。

何かのソースからパッケージを作ってみたい。
今回試すのはsquidにしてみる。

wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE13.tar.gz
tar zxfv squid-3.0.STABLE13.tar.gz
cd squid-3.0.STABLE13
./configure
make
make install
/usr/local/sbin/checkinstall -R

途中の入力は全部パスして進めると、最後にこう表示される。OKか?
**********************************************************************

Done. The new package has been saved to

/usr/src/redhat/RPMS/i386/squid-3.0.STABLE13-1.i386.rpm
You can install it in your system anytime using:

rpm -i squid-3.0.STABLE13-1.i386.rpm

**********************************************************************

とりあえず/usr/src/redhat/RPMS/i386/にrpmができているのは確認した。
しかし、このパッケージからインストールしようとするとgrepの競合というエラーが出る。
ソースからすでにインストールしたからかな?

postfix:インストールとmtaの切り替え

sendmailが入っているサーバにpostfixを入れるメモ。

まず、postfixのインストール

# yum install postfix

次に設定。/etc/postfix/main.cfに記述する。
# cp /etc/postfix/main.cf /etc/postfix/main.cf.org
# vi /etc/postfix/main.cf
/etc/postfix/main.cf
myhostname = 自ホスト名
mydomain = $mydomain
myorigin = $mydomain
#inet_interfaces = all
inet_interfaces = localhost
mynetworks_style = host
mynetworks = xxx.xxx.xxx.xxx
smtpd_banner = $myhostname ESMTP
home_mailbox = Maildir/

main.cfのパラメタ抜粋
パラメータ名説明
myhostname自ホスト名
DNSで引けるドメイン名であること。
mydomain自ドメイン名
postfixの名前解決に使用する。ホスト名を省略したとき、このlocalhost.$mydomainに送信される。
mynetworks_style信頼できるSMTPクライアントアドレス
host,subnet,classが指定できる。
mynetworks信頼できるSMTPクライアントアドレス
mynetworks_styleよりも詳細に設定するときに使う。,(カンマ)またはスペースで区切ってsabunetをいくつも設定できる。ここを設定するとmynetworks_styleは無視される。
home_mailboxmailboxの形式

mtaの切り替え。
# /usr/sbin/alternatives --config mta

There are 2 programs which provide 'mta'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.sendmail
   2           /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number:
ここでpostfix・・・2を選ぶ。

設定したらpostfixを起動&initスクリプトの登録。
# /etc/init.d/postfix start
# /sbin/chkconfig postfix on

sendmailは止める。
# /etc/init.d/sendmail stop
# /sbin/chkconfig sendmail off

必ず不正中継のテストをすること。 Mail relay testing

postfix:メールの保存形式と設定方法

postfixはメールをmbox、MailDir形式、cyrus形式で保存できる。デフォルトの設定ではmbox形式。

mbox、MailDirの違いはざっと↓。

mbox
全てのメールを1ファイルで保存する。
ファイルサイズは非常に大きくなる。サイズの大きくなったmboxにアクセスするとサーバ負荷は高くなる。
全てのメールが1ファイルで保存されているのでファイルが壊れたときの影響が大きい。また排他処理も同様の理由で不利である。

MailDir
ユーザディレクトリのMailDirフォルダ以下に1メールを1ファイルで保存する。
mbox形式の弱点が解消されるほか、MailDirフォルダに容量制限をかけることが出来る。
欠点はファイル増加によるパフォーマンス低下。

cyrus(よく解りません・・・)
ユーザディレクトリ以外の場所に1メールを1ファイルで保存する。
連携できるアプリが多いのが長所みたい。

設定方法
1.main.cfを編集してメールの保存方法を設定します。

/etc/postfix/main.cf
#home_mailbox = Mailbox
#home_mailbox = Maildir/
mbox形式ならMailbox、MailDir、cyrus形式ならMaildir/をコメントアウトする
※Maildir/は”/まで”必要!

2.postfixを再起動する
/etc/init.d/postfix restart

参考サイト: posyfixのぺーじ