LINK


(無償)
logo
世界中で使われるISO標準オフィスソフト(MSオフィス互換)
The Document Foundation Wiki

人気の投稿(1ヶ月間)

Ad

Ad

ラベル hylafax の投稿を表示しています。 すべての投稿を表示
ラベル hylafax の投稿を表示しています。 すべての投稿を表示

2019年3月17日日曜日

【Linux CentOS 7】HylaFAXをパッケージでお手軽に導入する【HylaFAX 6.0.7】

以下は、CentOS 7 をベースにした特権dockerコンテナにHylaFAXをインストールしたものである。

しかし、通常のCentOS 7にも、同じやり方でインストールできると思われる。

使用したDockerイメージは次のページで作成したものである。

【Linux CentOS 7】(ベースコンテナの作成)SSH接続可能なDockerコンテナでの日本用ロケールの有効化と検証(man,dateの日本語表示)【Docker-ce 18.06.1.ce】

sshで接続して、以下のようにインストール作業を行った。



○依存パッケージのインストール

# yum install libtiff
Package libtiff-4.0.3-27.el7_3.x86_64 already installed and latest version

Nothing to do

# yum install ghostscript
Updated:
  ghostscript.x86_64 0:9.07-31.el7_6.9

Dependency Updated:
  ghostscript-devel.x86_64 0:9.07-31.el7_6.9

Complete!

# yum install ghostscript-fonts
Package ghostscript-fonts-5.50-32.el7.noarch already installed and latest version

Nothing to do

システムに、mgetty-sendfax パッケージが導入されている場合は削除しておく。



○hylafaxパッケージのダウンロードとインストール

ダウンロードするものは二種類ある。

https://www.hylafax.org/binary-packages/redhat-packages/ からそれぞれダウンロードした。

# wget ftp://ftp.hylafax.org/binary/linux/redhat/6.0.7/hylafax-client-6.0.7-1.el7.x86_64.rpm

# wget ftp://ftp.hylafax.org/binary/linux/redhat/6.0.7/hylafax-server-6.0.7-1.el7.x86_64.rpm


# ls -l
total 1172
-rw-r--r-- 1 root root 378024 Mar  9 18:02 hylafax-client-6.0.7-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 815636 Mar  9 17:49 hylafax-server-6.0.7-1.el7.x86_64.rpm


最初にクライアントパッケージからインストールした。

# yum install hylafax-client-6.0.7-1.el7.x86_64.rpm
Installed:
  hylafax-client.x86_64 0:6.0.7-1.el7

Complete!

次にサーバーパッケージをインストールした。
(依存パッケージがダウンロードされ導入された。)

# yum install hylafax-server-6.0.7-1.el7.x86_64.rpm
Is this ok [y/d/N]: y

Downloading packages:
sharutils-4.13.3-8.el7.x86_64.rpm
                                                                | 252 kB
00:00:00   
Running transaction check
Running transaction test
Transaction test succeeded

Running transaction
  Installing : sharutils-4.13.3-8.el7.x86_64

1/2
install-info: No such file or directory for /usr/share/info/sharutils.info
  Installing : hylafax-server-6.0.7-1.el7.x86_64

2/2
#########################################################
#            HylaFAX installation complete!             #
#                                                       #
#      You should now run /usr/sbin/faxsetup to         #
#       create or update HylaFAX configuration          #
#      before you can begin using the software.         #
#                                                       #
#########################################################

  Verifying  : sharutils-4.13.3-8.el7.x86_64

1/2
  Verifying  : hylafax-server-6.0.7-1.el7.x86_64

2/2
Installed:
  hylafax-server.x86_64 0:6.0.7-1.el7

Dependency Installed:
  sharutils.x86_64 0:4.13.3-8.el7

Complete!

以上でhylafaxがインストールされた。



○systemctlでstatusを確認

# systemctl status hylafax
● hylafax.service - LSB: Starts and stops the HylaFAX
   Loaded: loaded (/etc/rc.d/init.d/hylafax; bad; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)
起動していないことがわかるようになった。



○hylafaxの基本セットアップ

予め、不可欠のパッケージを導入した。

# yum install libtiff-tools
Installed:
  libtiff-tools.x86_64 0:4.0.3-27.el7_3

Complete!

セットアップを行った。
ほとんどデフォルトの回答のままエンターを押すだけにした。
一部、値を設定する必要がある。

# faxsetup
Setup program for HylaFAX (tm) 6.0.7.
Created for x86_64-unknown-linux-gnu on Tue Sep 18 18:56:42 UTC 2018.
Found converter: /bin/tiff2pdf
Found uuencode encoder: /bin/uuencode
Found base64 encoder: /bin/base64
Found Quoted-Printable encoder: qp-encode
Looks like /bin/base64 supports base64 encoding.
Found mimencode for compatibilty: mimencode
Checking system for proper client configuration.
Checking system for proper server configuration.

Warning: /sbin/mgetty does not exist or is not an executable program!
The file:
    /sbin/mgetty
does not exist or this file is not an executable program.  The
HylaFAX software optionally uses this program and the fact that
it does not exist on the system is not a fatal error.  If the
program resides in a different location and you do not want to
install a symbolic link for /sbin/mgetty that points to your program
then you must reconfigure and rebuild HylaFAX from source code.

Warning: /sbin/vgetty does not exist or is not an executable program!
The file:
    /sbin/vgetty
does not exist or this file is not an executable program.  The
HylaFAX software optionally uses this program and the fact that
it does not exist on the system is not a fatal error.  If the
program resides in a different location and you do not want to
install a symbolic link for /sbin/vgetty that points to your program
then you must reconfigure and rebuild HylaFAX from source code.

Warning: /bin/egetty does not exist or is not an executable program!
The file:
    /bin/egetty
does not exist or this file is not an executable program.  The
HylaFAX software optionally uses this program and the fact that
it does not exist on the system is not a fatal error.  If the
program resides in a different location and you do not want to
install a symbolic link for /bin/egetty that points to your program
then you must reconfigure and rebuild HylaFAX from source code.
Searching for a default font.

Generating Fontmap /etc/hylafax/Fontmap.HylaFAX.

Found Courier to use as default font.

Setting font configuration in /etc/hylafax/hyla.conf.

Make /var/spool/hylafax/bin/ps2fax a link to /var/spool/hylafax/bin/ps2fax.gs.

Make /var/spool/hylafax/bin/pdf2fax a link to /var/spool/hylafax/bin/pdf2fax.gs.


There does not appear to be an entry for the FaxMaster either in
the YP/NIS database or in the /etc/aliases file.  The
FaxMaster is the primary point of contact for HylaFAX problems.
The HylaFAX client-server protocol server identifies this alias as
the place to register complaints and HylaFAX directs automatic mail
messages to this user when problems are identified on a server
machine or when the routine server maintainence scripts are run
(e.g. faxcron).
Should an entry be added for the FaxMaster to /etc/aliases [yes]?
Users to receive fax-related mail [root]?
Rebuilt /etc/aliases database.
Update /var/spool/hylafax/status/any.info.
HylaFAX configuration parameters are:
[1] Init script starts faxq: yes
[2] Init script starts hfaxd yes
[3] Start paging protocol: no
Are these ok [yes]?
Modem support functions written to /var/spool/hylafax/etc/setup.modem.
Configuration parameters written to /var/spool/hylafax/etc/setup.cache.
No scheduler config file exists, creating one from scratch.

Country code [1]? 81 ←日本は81である。
Area code []? xx ←市外局番から0を外したものを入力した。
Long distance dialing prefix [1]? 0
International dialing prefix [011]? 010 ←環境に応じたものを適当に入力した。


Dial string rules file (relative to /var/spool/hylafax) ["etc/dialrules"]?
Tracing during normal server operation [1]?
Default tracing during send and receive sessions [0xffffffff]?
Continuation cover page (relative to /var/spool/hylafax) []?
Timeout when converting PostScript documents (secs) [180]?
Maximum number of concurrent jobs to a destination [1]?
Define a group of modems []?
Time of day restrictions for outbound jobs ["Any"]?
Timeout before purging a stale UUCP lock file (secs) [30]?
Max number of pages to permit in an outbound job [0xffffffff]?
Syslog facility name for ServerTracing messages [daemon]?
The non-default scheduler parameters are:
CountryCode: 81
AreaCode: xx
LongDistancePrefix: 0
InternationalPrefix: 010
Are these ok [yes]?
Creating new configuration file /var/spool/hylafax/etc/config...

Restarting HylaFAX server processes.
Should I restart the HylaFAX server processes [yes]?

/etc/rc.d/init.d/hylafax start
Reloading systemd:                                         [  OK  ]
Starting hylafax (via systemctl):                          [  OK  ]

You do not appear to have any modems configured for use.  Modems are
configured for use with HylaFAX with the faxaddmodem(8C) command.
Do you want to run faxaddmodem to configure a modem [yes]? no ←IAXmodemを利用したいのでnoとした。
Done verifying system setup.
セットアップによって、設定ファイルが構成されて、hylafaxがstartされた。



○systemctlでstatusを確認

# systemctl status hylafax
hylafax.service - LSB: Starts and stops the HylaFAX
   Loaded: loaded (/etc/rc.d/init.d/hylafax; bad; vendor preset: disabled)
   Active: active (running) since Sat 2019-03-09 19:13:54 UTC; 3min 3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2275 ExecStart=/etc/rc.d/init.d/hylafax start (code=exited, status=0/SUCCESS)
   CGroup: /docker/28a9c6704dba75a8fdd17713c8745eec7d07d4b73608c071a327be787a35e66d/system.slice/hylafax.service
           ├─2282 /usr/sbin/faxq
           └─2287 /usr/sbin/hfaxd -i hylafax
Mar 09 19:13:54 28a9c6704dba systemd[1]: Starting LSB: Starts and stops the HylaFAX...
Mar 09 19:13:54 28a9c6704dba hylafax[2275]: Starting HylaFAX queue manager (faxq): [  OK  ]
Mar 09 19:13:54 28a9c6704dba hylafax[2275]: Starting HylaFAX server (hfaxd): [  OK  ]
Mar 09 19:13:54 28a9c6704dba FaxQueuer[2282]: HylaFAX (tm) Version 6.0.7
Mar 09 19:13:54 28a9c6704dba systemd[1]: Started LSB: Starts and stops the HylaFAX.
Mar 09 19:13:54 28a9c6704dba FaxQueuer[2282]: Copyright (c) 1990-1996 Sam Leffler
Mar 09 19:13:54 28a9c6704dba FaxQueuer[2282]: Copyright (c) 1991-1996 Silicon Graphics, Inc.
Mar 09 19:13:54 28a9c6704dba HylaFAX[2287]: Listening to 0.0.0.0:4559
Mar 09 19:13:54 28a9c6704dba HylaFAX[2287]: HylaFAX INET Protocol Server: restarted.


★IAXmodemのセットアップ方法は、次のページに記述しています。

https://akira-arets.blogspot.com/2019/03/linux-docker-iaxmodem1.3.0-centos7.html

★IAXmodemとHylaFAXの連携方法は、次のページを参照ください。

https://akira-arets.blogspot.com/2011/09/linux-centos56-iaxmodemhylafax.html
https://akira-arets.blogspot.com/2011/09/hylafaxfaxwinprint-hylafax.html



<参考>
・HylaFAX / Binary Package Install
< https://www.hylafax.org/hylafax-handbook/binary-package-install/ > 2019年3月17日

・HylaFAX / HylaFAX packaged in binary RPM and source SRPM format
< https://www.hylafax.org/binary-packages/redhat-packages/ > 2019年3月17日

・hylafax-client(1) - Linux man page
< https://linux.die.net/man/1/hylafax-client > 2019年3月17日

・What is the difference between `yum install` and `yum localinstall`?
< https://ask.fedoraproject.org/en/question/37721/what-is-the-difference-between-yum-install-and-yum-localinstall/ > 2019年3月17日

2019年3月16日土曜日

【Linux CentOS 7】iaxmodem 1.3.0のインストールとsystemctlによる操作【IAXmodem 1.3.0】

以下は、特権で動作するDockerコンテナのCentOS 7システムにiaxmodemを導入した記録である。

通常のCentOS 7でも問題なく同じ手順でインストール可能だと思う。


下記で用いているDockerコンテナは、次のページで作成したイメージをベースにしている。

【Linux CentOS 7】(ベースコンテナの作成)SSH接続可能なDockerコンテナでの日本用ロケールの有効化と検証(man,dateの日本語表示)【Docker-ce 18.06.1.ce】

sshで接続して、以下のようにインストール作業を行った。



■ 必要な前提パッケージをインストール

○コンパイラ類の導入
[root@233ca92a899f iaxmodem]# yum install gcc gcc-c++
Installed:
  gcc.x86_64 0:4.8.5-36.el7                                                        gcc-c++.x86_64 0:4.8.5-36.el7

Dependency Installed:
  cpp.x86_64 0:4.8.5-36.el7         glibc-devel.x86_64 0:2.17-260.el7_6.3     glibc-headers.x86_64 0:2.17-260.el7_6.3     kernel-headers.x86_64 0:3.10.0-957.5.1.el7 
  libgomp.x86_64 0:4.8.5-36.el7     libmpc.x86_64 0:1.0.1-3.el7               libstdc++-devel.x86_64 0:4.8.5-36.el7       mpfr.x86_64 0:3.1.1-4.el7

Dependency Updated:
  glibc.x86_64 0:2.17-260.el7_6.3                                                 glibc-common.x86_64 0:2.17-260.el7_6.3

Complete!

○makeコマンドの導入
[root@233ca92a899f libiax2]# yum install make
Installed:
  make.x86_64 1:3.82-23.el7

Complete!

○必要なパッケージのインストール1
[root@233ca92a899f iaxmodem]# yum install libjpeg libjpeg-devel libtiff libtiff-devel
Installed:
  libjpeg-turbo.x86_64 0:1.2.90-6.el7 libjpeg-turbo-devel.x86_64 0:1.2.90-6.el7
  libtiff.x86_64 0:4.0.3-27.el7_3     libtiff-devel.x86_64 0:4.0.3-27.el7_3

Dependency Installed:
  jbigkit-libs.x86_64 0:2.0-11.el7

Complete!

○必要なパッケージのインストール2
[root@233ca92a899f iaxmodem]# yum install ghostscript ghostscript-devel ghostscript-fonts sox
Installed:
  ghostscript.x86_64 0:9.07-31.el7_6.9
  ghostscript-devel.x86_64 0:9.07-31.el7_6.9
  ghostscript-fonts.noarch 0:5.50-32.el7
  sox.x86_64 0:14.4.1-6.el7

Dependency Installed:
  alsa-lib.x86_64 0:1.1.6-2.el7
  avahi-libs.x86_64 0:0.6.31-19.el7
  cups-libs.x86_64 1:1.6.3-35.el7
  dejavu-fonts-common.noarch 0:2.33-6.el7
  dejavu-sans-fonts.noarch 0:2.33-6.el7
  flac-libs.x86_64 0:1.3.0-5.el7_1
  fontconfig.x86_64 0:2.13.0-4.3.el7
  fontpackages-filesystem.noarch 0:1.44-8.el7
  freetype.x86_64 0:2.8-12.el7_6.1
  gsm.x86_64 0:1.0.13-11.el7
  lcms2.x86_64 0:2.6-3.el7
  libICE.x86_64 0:1.0.9-9.el7
  libSM.x86_64 0:1.2.2-2.el7
  libX11.x86_64 0:1.6.5-2.el7
  libX11-common.noarch 0:1.6.5-2.el7
  libXau.x86_64 0:1.0.8-2.1.el7
  libXext.x86_64 0:1.3.3-3.el7
  libXi.x86_64 0:1.7.9-1.el7
  libXt.x86_64 0:1.1.5-3.el7
  libXtst.x86_64 0:1.2.3-1.el7
  libao.x86_64 0:1.1.0-8.el7
  libasyncns.x86_64 0:0.8-7.el7
  libfontenc.x86_64 0:1.1.3-3.el7
  libogg.x86_64 2:1.3.0-7.el7
  libpng.x86_64 2:1.5.13-7.el7_2
  libsndfile.x86_64 0:1.0.25-10.el7
  libtool-ltdl.x86_64 0:2.4.2-22.el7_3
  libvorbis.x86_64 1:1.3.3-8.el7.1
  libxcb.x86_64 0:1.13-1.el7
  poppler-data.noarch 0:0.4.6-3.el7
  pulseaudio-libs.x86_64 0:10.0-5.el7
  urw-fonts.noarch 0:2.4-16.el7
  wavpack.x86_64 0:4.60.1-9.el7
  xorg-x11-font-utils.x86_64 1:7.5-21.el7
 
Complete!


■iaxmodem-1.3.0 のビルド

○次のページから、iaxmodem-1.3.0.tar.gz を取得した。
https://sourceforge.net/projects/iaxmodem/files/

[root@233ca92a899f iaxmodem]# ls
iaxmodem-1.3.0.tar.gz

○展開を行った。
[root@233ca92a899f iaxmodem]# tar zxvf iaxmodem-1.3.0.tar.gz

[root@233ca92a899f iaxmodem]# cd iaxmodem-1.3.0


○ビルドの方法は2種類あるのでいずれか適切な方を選ぶ。

1、スタティックビルド
 バイナリサイズが大きくなるため複数モデムインスタンスでメモリを圧迫するかもしれない。

2、ダイナミックリンクでビルド


★スタティックビルドの場合は次のようにビルドする。
[root@eea26ba1e777 iaxmodem-1.3.0]# ls
CHANGES      VERSION        iaxmodem-cfg.ttyIAX   iaxmodem.init.fedora
FAQ          build          iaxmodem.1            iaxmodem.init.suse
Makefile.in  compat         iaxmodem.c            iaxmodem.spec
README       config.ttyIAX  iaxmodem.inf          lib
TODO         configure      iaxmodem.init.debian  termpkg-ttydforfax.patch
[root@eea26ba1e777 iaxmodem-1.3.0]# ./build static
[root@eea26ba1e777 iaxmodem-1.3.0]# ls iaxmodem -l
-rwxr-xr-x 1 root root 1127296 Mar 15 17:00 iaxmodem ←スタティックビルドでは、サイズが1MBを超えている。


★ダイナミックリンクの場合は次のようにビルドする。

・一つ目のライブラリのインストール
[root@233ca92a899f iaxmodem-1.3.0]# cd lib/libiax2/
[root@233ca92a899f libiax2]# ./configure
[root@233ca92a899f libiax2]# make
[root@233ca92a899f libiax2]# make install
[root@233ca92a899f libiax2]# cd ../..

・二つ目のライブラリのインストール
[root@233ca92a899f iaxmodem-1.3.0]# cd lib/spandsp/
[root@233ca92a899f spandsp]# ./configure
[root@233ca92a899f spandsp]# make
[root@233ca92a899f spandsp]# make install
[root@233ca92a899f libiax2]# cd ../..

・ライブラリを利用できるようにする。
[root@233ca92a899f iaxmodem-1.3.0]# touch /etc/ld.so.conf.d/iaxmodem-i386.conf
[root@233ca92a899f iaxmodem-1.3.0]# echo '/usr/local/lib' >> /etc/ld.so.conf.d/iaxmodem-i386.conf
[root@233ca92a899f iaxmodem-1.3.0]# cat /etc/ld.so.conf.d/iaxmodem-i386.conf
/usr/local/lib
[root@233ca92a899f iaxmodem-1.3.0]# ldconfig

・ダイナミックリンクでビルドを行う。
[root@233ca92a899f iaxmodem-1.3.0]# ./build

-rwxr-xr-x 1 root root 81328 Mar 17 16:37 iaxmodem ←ダイナミックリンクでビルドすると81KB程度となった。

○ビルドしたバイナリをコピーした。
[root@233ca92a899f iaxmodem-1.3.0]# cp -p iaxmodem /usr/local/sbin/



■iaxmodemの起動スクリプトと設定ファイルの準備

○起動スクリプトの準備
[root@233ca92a899f iaxmodem-1.3.0]# cp -p iaxmodem.init.fedora /etc/init.d/iaxmodem
[root@233ca92a899f iaxmodem-1.3.0]# chmod +x /etc/init.d/iaxmodem

○オリジナル設定ファイルのコピー
[root@233ca92a899f iaxmodem-1.3.0]# mkdir /etc/iaxmodem
[root@233ca92a899f iaxmodem-1.3.0]# cp iaxmodem-cfg.ttyIAX /etc/iaxmodem

○設定ファイルの編集
ここでは、IAXmodemがASTERISKのIAXアカウントにレジストするための設定や、
IAXmodem自身であるデバイスファイル名の設定などを行う。
[root@233ca92a899f iaxmodem-1.3.0]# vi /etc/iaxmodem/iaxmodem-cfg.ttyIAX



■iaxmodemサービスをserviceもしくはsystemctlで始動

○旧serviceコマンドを使えるようにする。
[root@233ca92a899f iaxmodem-1.3.0]# yum install initscripts
Installed:
  initscripts.x86_64 0:9.49.46-1.el7                                         
Dependency Installed:
  sysvinit-tools.x86_64 0:2.88-14.dsf.el7                                     
Complete!

○状態の確認を行った。
まだ始動していない。
[root@233ca92a899f iaxmodem-1.3.0]# service iaxmodem status
● iaxmodem.service - SYSV: IAXModem for asterisk <-> Hylafax gateway
   Loaded: loaded (/etc/rc.d/init.d/iaxmodem; bad; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)

○LOGをとれるようにしておく。
[root@233ca92a899f iaxmodem-1.3.0]# mkdir /var/log/iaxmodem
[root@233ca92a899f iaxmodem-1.3.0]# touch /var/log/iaxmodem/iaxmodem


○始動試行1

service iaxmodem start もしくは、systemctl start iaxmodemを実行した。

そして、次のようにしてLOGを確認した。
[root@233ca92a899f iaxmodem-1.3.0]# cat /var/log/iaxmodem/iaxmodem
[2019-03-15 16:45:46.303632] Fatal error: uucp user not found in passwd file
[2019-03-15 16:45:46.304002] iaxmodem process 16812 terminated on Unknown signal 255.
[2019-03-15 16:45:46.304021] respawning process for config: iaxmodem-cfg.ttyIAX.
[2019-03-15 16:45:46.304043] waitpid returned: -1
[2019-03-15 16:45:46.304051] Terminating...
uucpユーザーが登録されていないため起動に失敗していることがわかった。


○uucpユーザーを追加した。
[root@233ca92a899f iaxmodem-1.3.0]# useradd --system uucp

○起動
[root@233ca92a899f iaxmodem-1.3.0]# systemctl start iaxmodem

LOGの確認を行った。
[2019-03-15 16:50:34.016139] Process 16881 started for config iaxmodem-cfg.ttyIAX.
[2019-03-15 16:50:34.016215] Modem started
設定ファイルに対応するモデムのデバイスファイルが作成された。
[root@233ca92a899f iaxmodem-1.3.0]# ls /dev/ttyIAX
/dev/ttyIAX



<参考>
・IAXmodem / Okay, now what?
< http://iaxmodem.sourceforge.net/howto.php > 2019年3月16日

・【Linux CentOS 5.7】 iaxmodemとhylafaxのインストールと基本設定作業
CentOS 5.7(64bit)に、iaxmodemとhylafaxをインストールする手順
< http://akira-arets.blogspot.com/2011/09/linux-centos56-iaxmodemhylafax.html > 2019年3月16日

2017年6月26日月曜日

【Linux CentOS6.9 64bit】HylafaxとIAXmodemを再起動する順序について【IAXmodem 1.2.0】【Hylafax+ 5.5.9】

Asterisk + IAXmodem + hylafax+ で、ファックスサーバを構築し動作させていたところ、
2ヶ月ほど連続稼動させたところで、急にファックスが受信できなくなってしまった。

とりあえず、IAXmodemと、hylafax+と、Asterisk の再起動を行った。

ところで、IAXmodemと、hylafax+の再起動において、その順序に注意が必要だったのでメモを残しておく。


<使用したバージョンについて>
hylafax+(5.5.9) は、CentOSにおいてyum(epelリポジトリ利用)で導入したものである。
IAXmodem(1.2.0)は、ソースから導入した。



■まず、Hylafax IAXmodemの関係について、faxgettyというプログラムと共に整理した。

IAXmodemは、動作中、/dev/IAXmodem のように、設定に応じたデバイスファイルを存在させる。
hylafaxは、faxgettyというプログラムでそれらのデバイスファイルとの関係を得る。

(例)
# /usr/sbin/faxgetty /dev/IAXmodem &

だから、IAXmodemを起動して、その後、hylafax+を起動し、そしてfaxgettyを実行する必要がある



■以下では、Hylafax+と、IAXmodemの再起動時の挙動を調べた。

○IAXmodemを再起動する場合 (Hylafaxは起動したままである。)

最初の状態である。faxgettyが動作している。
#  ps -aef | grep faxgetty
uucp     18305     1  0 04:15 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem

サービスを停止する。
# service iaxmodem stop

すでに実行中のfaxgettyは動作したままになってしまった。
#  ps -aef | grep faxgetty
uucp     18305     1  0 04:15 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem

しかし、2分ほど待ってから、調べてみると、動作していたfaxgettyのプロセスは消滅した。
#  ps -aef | grep faxgetty
root     18844  9964  0 04:17 pts/21   00:00:00 grep faxgetty

このとき、Hylafaxから以下のメールを受け取った。
Hylafaxが、faxgettyの引数に渡していたIAXmodemデバイスが利用できないことを検知したようである。
そのために、対応のfaxgettyプロセスはHylafaxによって消滅させられたのだと思う。

# tail /var/spool/mail/root
The HylaFAX software thinks that there is a problem with the modem
on device /dev/IAXmodem that needs attention; repeated attempts to
initialize the modem have failed.

Consult the server trace logs for more information on what is happening.

You will be notified again after 5 minutes if the problem persists.

サービスを再び起動した。
# service iaxmodem start



○Hylafax+を再起動する場合 (IAXmodemは起動したままである。)

#  ps -aef | grep faxgetty
uucp     18094     1  0 04:00 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem

サービスを停止する。
# service hylafax+ stop

しかし、これだけでは、すでに実行中のfaxgettyは動作したままになってしまった。
5分ほど放置してみたが、状況には変化がなかった。
faxgettyを監督しているHylafax本体が起動していないため、faxgettyは終了しないのだろうと思う。
#  ps -aef | grep faxgetty
uucp     18094     1  0 04:08 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem
そして、サービスを再び起動した。
# service hylafax+ start

サービスを再び起動した時に、動作していたfaxgettyのプロセスはただちに消滅した。
hylafaxは起動時には、動作しているfaxgettyプロセスを一掃するのではないかと思う。



■Hylafaxと、IAXmodemを再起動するためのスクリプトを作成した。

Hylafaxと、IAXmodemの再起動には、上記の性質を考慮して行う必要がある。
以下の手順で、Hylafaxと、IAXmodemを再起動すると良いだろう。

(1)Hylafaxの再起動(これによって、古いfaxgettyプロセスが消滅する。)
# service hylafax+ restart

古いfaxgettyプロセスはただちに一掃された。
#  ps -aef | grep faxgetty
root     20339  9964  0 04:34 pts/21   00:00:00 grep faxgetty

(2)IAXmodemの再起動
# service iaxmodem restart

(3)faxgettyをIAXmodemを引数につけて実行する。
# /usr/sbin/faxgetty /dev/IAXmodem &

#  ps -aef | grep faxgetty
uucp     20417     1  0 04:37 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem



(スクリプトにまとめた)

次のような再起動用スクリプトを作成したところ、うまく動作した。
念のため、待機時間を5秒挿入している。
例ではモデム数は一個だけだが、テスト環境においては20個程度存在していた。

(Asteriskは再起動に時間を要する場合があるので、一番最後が良いかもしれない。あるいは充分なウェイトを置いて最初に行う。)
/sbin/service hylafax+ restart
/bin/sleep 5s
/sbin/service iaxmodem restart
/bin/sleep 5s
/usr/sbin/faxgetty /dev/IAXmodem &

(注意)
逆の手順でIAXmodemから先に再起動させた場合、正しく動作しなかった
モデムが全て、waiting 状態のままになってしまった。



■ところで、defunctってなんだろうか。

uucp     20419     1  0 04:37 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem1
uucp     20420     1  0 04:37 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem2
uucp     20421     1  0 04:37 pts/21   00:00:00 /usr/sbin/faxgetty /dev/IAXmodem3
uucp     20446 20419  0 04:37 ?        00:00:00 [faxgetty] <defunct>
uucp     20447 20420  0 04:37 ?        00:00:00 [faxgetty] <defunct>
uucp     20484 20420  0 04:49 ?        00:00:00 [faxgetty] <defunct>
uucp     20485 20419  0 04:49 ?        00:00:00 [faxgetty] <defunct>
root     20528  9964  0 04:58 pts/21   00:00:00 grep faxgetty

着信を受けたIAXmodemに対応するfaxgettyプロセスについて、defunctとなった。
無害のようである。参考になるページを見つけた。



<参考>
・RE: [hylafax-users] "Waiting for modem to come ready" another
< http://www.hylafax.org/archive/2010-11/msg00128.php > 2017年6月24日

・Re: [hylafax-users] faxgetty <defunct> - 'Extra' FaxGetty
< http://www.hylafax.org/archive/2006-01/msg00322.php > 2017年6月24日

2011年9月22日木曜日

【Linux CentOS 5.7】 HylaFaxで複数のFAXモデムを追加しモデムグループを構成しWinprint HylaFAXから使い分ける

FAXサーバーソフトHylaFaxに複数のiaxmodemモデムを追加し加えてグループ化も行い、クライアントソフトであるWinPrint HylaFaxからそれらを指定してFAXの送出を行う方法について



Hylafaxサーバーに複数のモデムを追加しておき、クライアントソフトウェアから任意のモデムを指定してFAXを送出する。
各々のモデムに関連付けられた設定ファイルにより、そのファックス文書には経由するモデムごとにユニークなヘッダーインフォメーションを付加できる
このようにすると、1台のHylafaxを複数の部署から共有しながら、部署ごとに異なった送信元情報をファックス文書のヘッダーに載せられる。

これらの複数のモデムは、モデムグループに束ねて用いることもできる。
ある部署用の設定をした複数のモデムを一つのグループにまとめ、FAXクライアントソフトウェアでは送信の際にこのグループ名を指定して用いることができる。
そうすると、グループに所属するモデムのうちスタンバイ状態にある一つが自動的に選択される。
そのため、利用可能なモデムデバイス名を個別にクライアントで指定しなくても、同時に複数のFAXを送信することができる。




前提として、以下のソフトウェアが次のような手順で正常にインストールできていること。

<使用したソフトウェアとそのバージョン>

○FAXサーバー側
・Hylafax 6.0.5
・IAXmodem 1.2.0
・CentOS 5.7 (64bit)
⇒インストール方法はこちら

○FAXクライアント側 (動作チェックで使用するだけ)
・WinPrint HylaFax 1.0.0.7
・MS Windows 7 (64bit)
⇒インストール方法はこちら



■Hylafaxサーバー側の設定■

FAXモデムとして、ASTERISKと連携できるIAXmodemを使用した。


◇追加のIAXmodemを設定する

iaxmodemのインストール後には、/etc/iaxmodem/ttyIAXがたった一個だけ存在している。
このttyIAXには、iaxmodemモデムを生成するための情報が含まれている。
これをコピーして増やすだけで、iaxmodemモデムが複数準備できる。


ttyIAXファイルをコピーし、必要なiaxmodem数分、増やす。例として4つ増やすことにする。
コピー後、それぞれ内容を編集する。


各ファイル名は、下記に示す内容のdevice項目(生成させるデバイスファイル)の設定値に対応させると良い。
(注意) このdevice名には"_"アンダーバーを絶対に使わないこと。hylafaxが動作しなかった。
[root@localhost ~]# cp /etc/iaxmodem/ttyIAX /etc/iaxmodem/ttyIAX-first-01
[root@localhost ~]# cp /etc/iaxmodem/ttyIAX /etc/iaxmodem/ttyIAX-second-01
[root@localhost ~]# cp /etc/iaxmodem/ttyIAX /etc/iaxmodem/ttyIAX-first-02
[root@localhost ~]# cp /etc/iaxmodem/ttyIAX /etc/iaxmodem/ttyIAX-second-02

コピーしたttyIAX-firstファイルを編集する
[root@localhost ~]# vim /etc/iaxmodem/ttyIAX-first-01
device          /dev/ttyIAX-first-01  ←生成させるデバイスファイルは、iaxmodemの設定ファイル名と一致させると良い。(前述したとおり、アンダーバーは絶対に使わないこと。)
owner           uucp:uucp
mode            660
port            4570
refresh         300
server          asterisk-server-address
peername        iaxmodem-first-01  ←当然、他のpeernameと重ならないようにする
secret          password
cidname         John Doe
cidnumber       8005551212
codec           slinear

コピーしたttyIAX-secondファイルを編集する
[root@localhost ~]# vim /etc/iaxmodem/ttyIAX-second-01
device          /dev/ttyIAX-second-01
owner           uucp:uucp
mode            660
port            4570
refresh         300
server          asterisk-server-address
peername        iaxmodem-second-01
secret          password
cidname         John Doe
cidnumber       8005551212
codec           slinear

同様にして、コピーしたttyIAX-thirdファイルを編集する
[root@localhost ~]# vim /etc/iaxmodem/ttyIAX-first-02
同様にして、コピーしたttyIAX-fourthファイルを編集する
[root@localhost ~]# vim /etc/iaxmodem/ttyIAX-second-02


合せて、ASTERSISK側のiax.confの設定も行う
[root@asterisk ~]# vim /etc/asterisk/iax.conf
[iaxmodem]
type=friend
username=iaxmodem
secret=password
host=dynamic
disallow=all
allow=ulaw
allow=slinear
requirecalltoken=no
context=fax_outgoing

[iaxmodem-first-01]  ←今回追加したiaxmodemに対応するASTERISKの設定
type=friend
username=iaxmodem-first-01
secret=password
host=dynamic
disallow=all
allow=ulaw
allow=slinear
requirecalltoken=no
context=fax_outgoing

[iaxmodem-second-01] ←今回追加したiaxmodemに対応するASTERISKの設定
type=friend
username=iaxmodem-second-01
secret=password
host=dynamic
disallow=all
allow=ulaw
allow=slinear
requirecalltoken=no
context=fax_outgoing
[iaxmodem-first-02] ←今回追加したiaxmodemに対応するASTERISKの設定
type=friend
username=iaxmodem-first-02
secret=password
host=dynamic
disallow=all
allow=ulaw
allow=slinear
requirecalltoken=no
context=fax_outgoing
[iaxmodem-second-02] ←今回追加したiaxmodemに対応するASTERISKの設定
type=friend
username=iaxmodem-second-02
secret=password
host=dynamic
disallow=all
allow=ulaw
allow=slinear
requirecalltoken=no
context=fax_outgoing

これで、iaxmodem増設の設定は完了した。

service iaxmodem restartコマンドでiaxmodemを再起動させる。
IAXmodemの起動後に、iaxmodemが増設される。
/dev/ディレクトリ以下に次のデバイスファイルが作成されているはず。
ttyIAX-first-01
ttyIAX-first-02
ttyIAX-second-01
ttyIAX-second-02

faxgettyに、今回追加した新モデムを渡すための追加設定を行う
[root@localhost etc]# vim /etc/inittab
(略)
# Run faxgetty in standard runlevels
iah0:2345:respawn:/usr/local/sbin/faxgetty /dev/ttyIAX
iah1:2345:respawn:/usr/local/sbin/faxgetty /dev/ttyIAX-first-01
iah2:2345:respawn:/usr/local/sbin/faxgetty /dev/ttyIAX-first-02
iah3:2345:respawn:/usr/local/sbin/faxgetty /dev/ttyIAX-second-01
iah4:2345:respawn:/usr/local/sbin/faxgetty /dev/ttyIAX-second-02
(略)



◇hylafaxの設定ファイルを追加する

hylafaxには、FAXモデムごとに設定ファイルが存在している。
これは、使用されるモデムのデバイス名に基づいて、ファックス送出の際に使用される設定ファイルである。選択されるモデムごとに、ファックス文書のタグ(ヘッダー)に記載するインフォメーションなどを設定しておける。

hylafaxの設定ファイルが置かれるディレクトリへ移動し、モデムデバイス毎の設定ファイルをコピーする。
この設定ファイル名は、config.モデムデバイス名という形式になっている。
[root@localhost ~]# cd /var/spool/hylafax/etc/
[root@localhost etc]# cp config.ttyIAX config.ttyIAX-first-01
[root@localhost etc]# cp config.ttyIAX config.ttyIAX-second-01
[root@localhost etc]# cp config.ttyIAX config.ttyIAX-first-02
[root@localhost etc]# cp config.ttyIAX config.ttyIAX-second-02


一つ目のモデムの設定ファイルを編集する(例)
[root@localhost etc]# vim config.ttyIAX-first-01
CountryCode:            81
AreaCode:               xx
FAXNumber:              +81.xxx.xxx.xxx
LongDistancePrefix:     0
InternationalPrefix:    xxx
DialStringRules:        etc/dialrules
ServerTracing:          0xFFF
SessionTracing:         0xFFF
RecvFileMode:           0600
LogFileMode:            0600
DeviceMode:             0600
RingsBeforeAnswer:      1
SpeakerVolume:          off
GettyArgs:              "-h %l dx_%s"
LocalIdentifier:        "example Co.Ltd. FIRST BRANCH"  ←ファックス送信元情報
TagLineFont:            etc/lutRS18.pcf
TagLineFormat:          "From %%l %%n   |%c   Page %%P of %%T"  ←ファックスヘッダーのフォーマット(意味は下に記載)
MaxRecvPages:           200
#
(以下省略)

ファックスヘッダーフォーマットで使われている記号の意味
%%l  ・・・LocalIdentifier項目の値
%%n ・・・FAXNumber項目の値
%c ・・・現在の日時
| ・・・ファックス文書のヘッダー領域を左右に均等に区分するもの(上の例では、二分される)

二つ目のモデムの設定ファイルを編集する(例)
[root@localhost etc]# vim config.ttyIAX-second-01
CountryCode:            81
AreaCode:               xx
FAXNumber:              +81.yyy.yyy.yyy
LongDistancePrefix:     0
InternationalPrefix:    xxx
DialStringRules:        etc/dialrules
ServerTracing:          0xFFF
SessionTracing:         0xFFF
RecvFileMode:           0600
LogFileMode:            0600
DeviceMode:             0600
RingsBeforeAnswer:      1
SpeakerVolume:          off
GettyArgs:              "-h %l dx_%s"
LocalIdentifier:        "example Co.Ltd. SECOND BRANCH"  ←ファックス送信元情報
TagLineFont:            etc/lutRS18.pcf
TagLineFormat:          "From %%l %%n   |%c   Page %%P of %%T"  ←ファックスヘッダーのフォーマット
MaxRecvPages:           200
#
(以下省略)

他のモデムについても、送信元情報などについて編集しておく
[root@localhost etc]# vim config.ttyIAX-first-02
[root@localhost etc]# vim config.ttyIAX-second-02


ロケールを英語に切り替える(ファックス文書に印字される日本語の日付が文字化けするため
[root@localhost ~]# date
2011年  9月 26日 月曜日 19:14:05 JST  ←初めはこのように日本語で表記されていた
[root@localhost ~]# cat /etc/sysconfig/i18n
LANG="ja_JP.UTF-8"  ←変数の値は、書き換え前このようになっていた
[root@localhost ~]# vim /etc/sysconfig/i18n
LANG="en_US.UTF-8"
[root@localhost ~]# date
Mon Sep 26 19:18:18 JST 2011  ←再起動後に英語表記に切り替わった(再起動はあとで)


hylafaxサーバー側の設定は、これで完了したので、設定を有効化するためシステムの再起動を行う
[root@localhost etc]# reboot


再起動後、faxstatコマンドを実行し、追加したモデムが有効になっているか確認する。
[root@localhost etc]# faxstat
HylaFAX scheduler on localhost.localdomain: Running
Modem ttyIAX (+81.nnn.nnn.nnn): Running and idle
Modem ttyIAX-first-01 (+81.xxx.xxx.xxx): Running and idle
Modem ttyIAX-first-02 (+81.xxx.xxx.xxx): Running and idle
Modem ttyIAX-second-01 (+81.yyy.yyy.yyy): Running and idle
Modem ttyIAX-second-02 (+81.yyy.yyy.yyy): Running and idle


◇必要なら、次のようにしてモデムをモデムグループに束ねる設定も行う

○configファイル内に、次のようにモデムグループの定義を追加する。
[root@localhost ~]# vim /var/spool/hylafax/etc/config
(例)
ModemGroup:             "first-branch:ttyIAX-first-(01|02)"
ModemGroup:             "second-branch:ttyIAX-second-(01|02)"
次のような書式になっている。
ModemGroup: "モデムグループ名:正規表現によるモデムデバイス名の指定"

上の例では、first-branchという名のモデムグループには、モデムデバイスのttyIAX-first-01ttyIAX-first-02を所属させ、
second-branchという名のモデムグループには、ttyIAX-second-01ttyIAX-second-02を所属させている。

(注意) 正規表現文字列-ttyIAX-first-(01|02)の部分-は、24文字以内に収めないと動作しなかった。


○さらに構成したモデムグループに属す複数のモデムを使って同時送信を行うために、
同時送信許可を設定する。
[root@localhost ~]# vim /var/spool/hylafax/etc/destctrls
.*      MaxConcurrentJobs = unlimited

「.*」は、正規表現。相手先の電話番号を表す。
「.」が全ての1文字を表し「*」は0回以上の繰り返しを意味しているので、これは全ての文字列に該当する表現になっている。
つまり、どの相手先にも同時送信数を無制限に設定している。
この設定を書き込まなければ、同時送信することができない。


○設定の後、hylafaxサービスを再起動させる。
[root@localhost ~]# service hylafax restart
Stopping HylaFAX Servers.
HylaFAX: faxq hfaxd (without SNPP support).


(参考)
Handbook:Advanced Server Configuration:Modem Groups
< http://www.hylafax.org/content/Handbook:Advanced_Server_Configuration:Modem_Groups > 2011/10/21

Re: [hylafax-users] Designating group of modems to specific task
< http://www.hylafax.org/archive/2004-02/msg00069.php > 2011/10/21



■Hylafaxクライアント側の設定■
Hylafaxクライアントとして、Windows7にインストールした「WinPrint Hylafax」を取り上げる。
⇒インストール方法はこちら


WinPrint Hylafax側では、FAX送出で使用するモデムのデバイス名を予め指定できる
この機能を使うことで、任意のFAXモデムを指定してFAXの送出が行える
そうして、関連付けられた設定ファイルに基づきファックス文書のヘッダーに指定した送出元を印字させられる。


◇モデムデバイスあるいはモデムグループを指定する手順

スタートボタンから「デバイスとプリンター」を開く。

インストールしておいた「FAXデバイス」で右クリックメニューを表示させ、「プリンタのプロパティー(P)」を開く。

ポートタブを選び、設定済みの「HFAX:」ポートを選び、「ポートの構成」ボタンをクリックする。

「Printer port settings」ウインドウが開く。

6番目にあるmodem項目を編集する。次の例のように、使用したいモデムデバイス名あるいはモデムグループ名を入力し、「OK」ボタンを押す。

・モデムデバイス名を指定する場合
(例)ttyIAX-second-02
・モデムグループを指定する場合
(例)first-branch

ここで指定したFAXモデムは、hylafaxサーバー側においてFAX送出で使用される。
また、ここで指定したモデムグループは、hylafaxにより解釈され、その所属モデムのうちスタンバイになっているものが使用される。

こうして送出されるファックス文書には、経由するFAXモデムに関連付けられた設定ファイルに基づき、特定の発信元などが印字された。


2011年9月18日日曜日

【MS Windows7】 HylafaxのクライアントソフトウェアWinPrint HylaFaxを使ってfaxを送信する

Windows7(64bit)に、HylafaxのクライアントソフトであるWinPrint HylaFaxをインストールしFAXを送信する手順


HylaFaxサーバーとそのクライアントソフトウェアを連携させることで、リモートのIPネットワーク上にあるWindows、Mac、Linuxクライアントなどから、プリントアウトする要領で手軽にFAXを送ることが可能になる。

以下は、WinPrint HylaFaxというWindows用のクライアントソフトウェアのインストール手順である。

(前提条件)
http://akira-arets.blogspot.com/2011/09/linux-centos56-iaxmodemhylafax.html に、iaxmodemとhylafaxのインストール手順あり。



作業手順
とくに断りがない限り、Windows7側での操作である。

□クライアントソフトウェアであるWinPrint HylaFaxをダウンロードする

http://www.hylafax.org/content/Desktop_Client_Softwareのリンクリストから、Winprint HylaFAX for Windows 7のページを開く。
ダウンロードリンク からWinPrintHylafax-for-Windows7.7zをダウンロードする。


□インストール作業を行う

(注意)新しいバージョンでは、インストール方法が全く変わっているかもしれない。

7z形式で圧縮されているので解凍し、WinPrintHylafax-for-Windows7-Release_ENGフォルダを取り出す。

この内にさらに、Only-For-Windows-64bitと、Only-For-Windows-32bitというフォルダがある。
Windows7 64bitの場合は、Only-For-Windows-64bitフォルダを取り出す。

内に、3つのファイルがあるので、そのうち次の2つのファイルを選択する。
HylaPrintUI.exe
HylaPrintMon.dll
これら2つのファイルを、C:\Windows\System32にコピーする。
(このとき、windows標準のエクスプローラーを使用すること。)

そうしてから、あと一つのHylaPrintMonReg.exeを「管理者として実行」し、INSTALLボタンをクリックする。INSTALL-OK.が表示されると成功。

(Error number:3006が表示される場合、UNINSTALLボタンをクリックしてから、INSTALLボタンを押してみると解決するかもしれない。 )



□「プリンタ」を追加する

「デバイスとプリンタ」から、「プリンタの追加」ボタンをクリックする。

「ローカルプリンタを追加します(L)」をクリックする。
「新しいポートの作成(C)」を選び、ポートの種類としてWinprint Hylafaxを選択し、次へ進む。

開いたウインドウには、HFAX1:と表示されているので、OKをクリックする。

プリンターの追加ウインドウが開くので、次の通りに選択し、次へ進む。
製造元:   Xerox
プリンター:  Xerox Phaser 6120PS

後は、必要に応じて適当に設定して進めばよい。
ただし、プリンター名は、FAXとしておくと分かりやすい



□Hylafaxの動作しているLinuxマシンで、FAXユーザーを追加する

先ず、Linuxユーザーとして追加し、Linuxパスワードを設定する
[root@localhost ~]# useradd myname
[root@localhost ~]# passwd myname
それから、このユーザーを次のようにFAXユーザーとして追加する
[root@localhost ~]# faxadduser myname


□「プリンタ」を設定する

追加したプリンタのアイコンを右クリックし、メニューから「プリンタのプロパティー(P)」を開く
ポートタブから、HAFX1: WinPrint Hylafax Port ・・・を選び、「ポートの構成(C)」ボタンをクリックする。

Printer port settingウインドウが開く。
次の基本項目を編集する。上で設定したFAXユーザー情報を入力する
・ Hylafax server: 192.168.1.1  ←Hylafaxが動作しているLinuxマシンのアドレス(ファイアーウォールは開いていますか?)
・ User name: myname  ←faxuseraddで追加したLinuxユーザー
・ Password: mypswd  ←Linuxログインパスワード

また、Email:項目に電子メールアドレスを設定しておくと、FAXの送達状態をHylafaxがメールで通知してくれる。
(ただし、サーバーでsendコマンドを使ってメールが送信できるようにしておく必要がある。)
Nortification:項目で、その通知が行われるイベントを設定できるようになっている。

○ところで、6番目にあるmodem:項目には、FAX送信で使用するモデムデバイスやモデムグループを指定することもできる。
この機能を使って経由するモデムを切り替えることで、ファックス文書に印字する発信元などの情報も自動的に切り替えることが可能。
さらにまた、モデムグループを使えば、グループに所属させているいくつかのモデムのうちスタンバイ状態にあるものが一つ自動的に選択されるようになるので、同時に複数のFAX送信を行えるようになる。
⇒詳細はこちらを参照



□FAXを送信してみる。

テスト用の文書を適当なアプリケーションから開き、上で追加したプリンタを使って印刷する。
Send Faxというウインドウが開くので、「FAX number:」に相手先電話番号を入力し、「Send FAX」ボタンをクリックする。

次のような経路でFAXが送出される。
アプリケーション→ WinPrint Hylafax→ hylafax→ iaxmodem→ ASTERISK→ 電話回線

数秒後に、電話回線につながった相手先のFAX機で着信し、文書を受信することができた。

【Linux CentOS 5.7】 iaxmodemとhylafaxのインストールと基本設定作業

CentOS 5.7(64bit)に、iaxmodemとhylafaxをインストールする手順

HylaFaxというFAXサーバとそのクライアントソフトウェアを使えば、ネットワークを通じてWindowsマシンなどから手軽にFAXを送信することができるようになる。
さらに、HylaFaxで使用するモデムとしてiaxmodemを使えば、Asteriskと連携することができるようになる。

(前提)ASTERISKのインストールが完了していて、外線への発信ができていること。


今回、CentOS 5.7(64bit)にインストールしたバージョン
・iaxmodem-1.2.0
・hylafax-6.0.5

(注意)
この条件でインストールした場合、コマンドラインからsendfaxコマンドを使ってFAXを送出しようとしても、フォント周りのエラーが表示されできなかった。
しかし、そのような状態でも、代わりにhylafaxのクライアントソフト(たとえば、Hylafax WinPrint)を用いれば、正常にFAXを送出することができた
クライアントソフトを使った場合、sendfaxコマンドで必要だったプロセスがクライアントソフト上で解決されたために、FAXを送出できたのだろう。
FAXサーバーとしての本質的な機能は正常にインストールされているようだ。クライアントソフトウェアを使ってFAXを送出するなら、この条件でも問題はないと思う。(後述)

○クライアントソフトであるHylafax WinPrintのインストール手順については次のページに記載。
http://akira-arets.blogspot.com/2011/09/ms-windows7-winprint-hylafaxfax.html



■インストール共通手順■

◇システムを最新にアップデートする。

[root@localhost ~]# yum update
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-238.19.1.el5 #1 SMP Fri Jul 15 07:31:24 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux


◇コンパイルに必要なモノをインストールする。

[root@localhost ~]# yum install gcc gcc-c++
Installed:
  gcc.x86_64 0:4.1.2-51.el5 gcc-c++.x86_64 0:4.1.2-51.el5
Dependency Installed:
  cpp.x86_64 0:4.1.2-51.el5 glibc-devel.x86_64 0:2.5-65 glibc-headers.x86_64 0:2.5-65 kernel-headers.x86_64 0:2.6.18-274.3.1.el5 libstdc++-devel.x86_64 0:4.1.2-51.el5

Complete!

 
■iaxmodemのインストールと設定■


◇必要なライブラリをインストールする

[root@localhost ~]# yum install libjpeg libjpeg-devel libtiff libtiff-devel
Installed:
  libjpeg-devel.i386 0:6b-37         libjpeg-devel.x86_64 0:6b-37         libtiff-devel.i386 0:3.8.2-7.el5_6.7         libtiff-devel.x86_64 0:3.8.2-7.el5_6.7

Complete!
[root@localhost ~]# yum install ghostscript ghostscript-devel ghostscript-fonts sox
Installed:
  ghostscript.i386 0:8.70-6.el5_7.3    ghostscript.x86_64 0:8.70-6.el5_7.3    ghostscript-devel.i386 0:8.70-6.el5_7.3    ghostscript-devel.x86_64 0:8.70-6.el5_7.3
  sox.x86_64 0:12.18.1-1.el5_5.1

Dependency Installed:
  alsa-lib.x86_64 0:1.0.17-1.el5  ghostscript-fonts.noarch 0:5.50-13.1.1  libICE.i386 0:1.0.1-2.1             libSM.i386 0:1.0.1-3.1        libXt.i386 0:1.0.2-3.2.el5
  libXt.x86_64 0:1.0.2-3.2.el5    libogg.x86_64 2:1.1.3-3.el5             libvorbis.x86_64 1:1.1.2-3.el5_4.4  urw-fonts.noarch 0:2.3-6.1.1

Complete!

◇iaxmodemをダウンロードしインストールを行う
 
[root@localhost iaxmodem]# wget http://sourceforge.net/projects/iaxmodem/files/iaxmodem/iaxmodem-1.2.0/iaxmodem-1.2.0.tar.gz/download
`iaxmodem-1.2.0.tar.gz' へ保存完了 [3075769/3075769]
[root@localhost iaxmodem]# tar zxvf iaxmodem-1.2.0.tar.gz

[root@localhost iaxmodem]# cd iaxmodem-1.2.0
[root@localhost iaxmodem-1.2.0]#

一つ目のライブラリをインストールする。
[root@localhost iaxmodem-1.2.0]# cd lib/libiax2/
[root@localhost libiax2]# ./configure
[root@localhost libiax2]# make
[root@localhost libiax2]# make install
[root@localhost libiax2]# cd ../..
[root@localhost iaxmodem-1.2.0]#

二つ目のライブラリをインストールする。
[root@localhost iaxmodem-1.2.0]# cd lib/spandsp/
[root@localhost spandsp]# ./configure
[root@localhost spandsp]# make
[root@localhost spandsp]# make install
[root@localhost spandsp]# cd ../..
[root@localhost iaxmodem-1.2.0]#

これらのライブラリをシステムに登録する。すでに/usr/local/libが登録されていればこの作業は不要。
[root@localhost iaxmodem-1.2.0]# touch /etc/ld.so.conf.d/iaxmodem-i386.conf
[root@localhost iaxmodem-1.2.0]# echo '/usr/local/lib' >> /etc/ld.so.conf.d/iaxmodem-i386.conf
[root@localhost iaxmodem-1.2.0]# cat /etc/ld.so.conf.d/iaxmodem-i386.conf
/usr/local/lib
[root@localhost iaxmodem-1.2.0]# ldconfig

ビルドしてバイナリを生成し、パスの通ったディレクトリにコピーする。
[root@localhost iaxmodem-1.2.0]# ./build
[root@localhost iaxmodem-1.2.0]# ls ./iaxmodem
./iaxmodem
[root@localhost iaxmodem-1.2.0]# cp -p iaxmodem /usr/local/sbin/


◇設定ファイルを編集する

ディレクトリを作成し、iaxmodemの設定ファイルをコピーする。
[root@localhost iaxmodem-1.2.0]# mkdir /etc/iaxmodem
[root@localhost iaxmodem-1.2.0]# cp -p iaxmodem-cfg.ttyIAX /etc/iaxmodem/ttyIAX
[root@localhost iaxmodem-1.2.0]# vim /etc/iaxmodem/ttyIAX
device          /dev/ttyIAX
owner           uucp:uucp
mode            660
port            4570
refresh         300
server          127.0.0.1  ←ASTERISKの動作しているコンピューター
peername        iaxmodem ASTERISKのiax.confで設定するもの
secret          password
cidname         John Doe
cidnumber       8005551212
codec           slinear

ASTERISKのiax.confサンプルファイルの一番下に、このiaxmodemに対応した設定を追加する
[root@asterisk asterisk]# vim /etc/asterisk/iax.conf
(略)
[iaxmodem]
type=friend
username=iaxmodem
secret=password
host=dynamic
disallow=all
allow=ulaw ←実際の運用時にはulawが用いられた。
allow=slinear
requirecalltoken=no
context=fax_outgoing
(略)
念のため挙げると、[general]項目は次のようにした。
[general]
autokill=yes
maxregexpire = 300
iaxcompat=yes
language=jp
bandwidth=high
disallow=all
allow=slinear
allow=ulaw
allow=alaw
jitterbuffer=no ←yesにするとFAX伝送に時間がかかった。noのままにする。
forcejitterbuffer=no


ASTERISKのextensions.confに、fax送信用のコンテクストとエクステンションを追加する
[root@asterisk asterisk]# vim /etc/asterisk/extensions.conf
[fax_outgoing]
exten => _0.,1,Dial(SIP/${EXTEN}@外線発信用デバイス名)

ASTERISKを再起動させる
[root@asterisk asterisk]# service asterisk restart



◇iaxmodemを自動起動させるための設定

[root@localhost iaxmodem-1.2.0]# cp -p iaxmodem.init.fedora /etc/init.d/iaxmodem
[root@localhost iaxmodem-1.2.0]# chmod +x /etc/init.d/iaxmodem
[root@localhost iaxmodem-1.2.0]# chkconfig --add iaxmodem
[root@localhost iaxmodem-1.2.0]# chkconfig iaxmodem on
[root@localhost iaxmodem-1.2.0]# chkconfig --list | grep iaxmodem
iaxmodem        0:off   1:off   2:on    3:on    4:on    5:on    6:off

◇iaxmodemのログ用ファイルを置く
[root@localhost iaxmodem-1.2.0]# mkdir /var/log/iaxmodem
[root@localhost iaxmodem-1.2.0]# touch /var/log/iaxmodem/iaxmodem


◇IAXmodemを起動する
[root@localhost iaxmodem-1.2.0]# service iaxmodem start

IAXmodem を起動中:                                         [  OK  ]
[root@localhost iaxmodem-1.2.0]# ls /dev/ | grep ttyIAX
ttyIAX    ・・・デバイスが作成されている


◇念のため、Asterisk側で、iaxmodemが正常にレジストされているか確認する

Asterisk CLIを起動し、iax2のレジスト状況を確認する
[root@asterisk asterisk]# asterisk -r
asterisk-01*CLI> iax2 show peers 
Name/Username    Host                 Mask             Port          Status
iaxmodem/iaxmod  192.168.xxx.yyy  (D)  255.255.255.255  58553         Unmonitored
設定したiaxmodemモデムが、192.168.xxx.yyyからレジストしていることが分かる。



以上で、iaxmodemのセッティングは完了。


◇initでiaxmodemを起動する設定を行う

エディタをつかって、斜体で書かれた行を挿入する。
[root@localhost iaxmodem-1.2.0]# vim /etc/inittab
(略)
# Run gettys in standard runlevels
(略)
# Run iaxmodem in standard runlevels
im1:2345:respawn:/usr/local/sbin/iaxmodem ttyIAX

(略)

引数のttyIAXは、後で/etc/iaxmodemディレクトリに置かれる設定ファイルである。

◇試しに起動して、チェックを行う

システムの再起動を行い、iaxmodemを起動させる。
[root@localhost ~]# reboot

再起動後、プロセスを確認する。
[root@localhost ~]# ps -A | grep iaxmodem
 3043 pts/0    00:00:00 iaxmodem
iaxmodemのデバイスファイルが生成されていることを確認する。
[root@localhost ~]# ls /dev/ttyIAX
/dev/ttyIAX



■hylafaxのインストールと設定■

以下はソースからインストール手順である。

しかし、代わりにyumを用いてパッケージからインストールすることもできる。
(下記リンクの手順で、Hylafax+ 5.5.9 のインストールができた。)
http://akira-arets.blogspot.jp/2017/07/linux-centos69-hylafaxplus-installing.html



◇必要なモノをインストールする

[root@localhost ~]# yum install mgetty-voice zlib-devel
Installed:
  mgetty-voice.x86_64 0:1.1.33-9.fc6                        zlib-devel.i386 0:1.2.3-4.el5                        zlib-devel.x86_64 0:1.2.3-4.el5

Complete!


◇hylafaxをダウンロードしインストールを行う

[root@localhost hylafax]# wget ftp://ftp.hylafax.org/source/hylafax-6.0.5.tar.gz
`hylafax-6.0.5.tar.gz' へ保存終了 [1295267]
[root@localhost hylafax]# tar xvfz hylafax-6.0.5.tar.gz
[root@localhost hylafax]# cd hylafax-6.0.5
[root@localhost hylafax-6.0.5]#

[root@localhost hylafax-6.0.5]# ./configure
(省略)
Press Return to Continue
番号を指定し値を入力し、パラメーターを変更する。

HylaFAX configuration parameters (part 1 of 2) are:

[ 1] Directory for applications:        /usr/local/bin
[ 2] Directory for lib data files:      /usr/local/lib/fax
[ 3] Directory for lib executables:     /usr/local/sbin
[ 4] Directory for system apps:         /usr/local/sbin
[ 5] Directory for manual pages:        /usr/local/man
[ 7] Directory for spooling:            /var/spool/hylafax
[ 8] Directory for uucp lock files:     /var/lock
[ 9] Uucp lock file scheme:             ascii
[10] PostScript imager package:         gs
[11] PostScript imager program:         /usr/bin/gs
[12] Manual page installation scheme:   bsd-source-cat
[13] Default page size:                 North American Letter
[14] Default vertical res (lpi):        98
次のように質問されるので、パラメーター番号を指定する。
Are these ok [yes]? 13
設定値がわからなければ、?を入力して、説明を表示させる。
Default page size [North American Letter]? ?

"?" is not a known page size; the following are known page sizes:

Name                    Abbrev  Width   Height  Width   Height  Top     Left


ISO A3                  A3      14030   19840   13200    18480  472     345
ISO A4                  A4       9920   14030    9240    13200  472     345
ISO A5                  A5       7133    9921    6455     9236  472     345
ISO A6                  A6       5055    6991    4575     6508  472     345
ISO B4                  B4      12048   17196   11325    16010  472     345
North American Letter   NA-LET  10200   13200    9240    12400  472     345
American Legal          US-LEG  10200   16800    9240    15775  472     345
American Ledger         US-LED  13200   20400   11946    19162  472     345
American Executive      US-EXE   8700   12600    7874    11835  472     345
Japanese Letter         JP-LET   8598   12141    7600    10200  900     400
Japanese Legal          JP-LEG  12141   17196   11200    15300  900     400
設定できる値がわかったので、A4を指定する。
Default page size [North American Letter]? A4
さらに、14番のパラメーターの値も変更する。
Are these ok [yes]? 14
同様に、設定可能な値リストを表示させる。
Default vertical res (lpi) [98]? ?
ファインモードを設定するので、196を入力する。
"?" is not a valid vertical resolution; choose either "98" lines/inch
(low resolution) or "196" lines/inch (often called fine resolution)
.
Default vertical res (lpi) [98]? 196
入力された値に変更されたパラメーターリストが表示される。
HylaFAX configuration parameters (part 1 of 2) are:

[ 1] Directory for applications:        /usr/local/bin
[ 2] Directory for lib data files:      /usr/local/lib/fax
[ 3] Directory for lib executables:     /usr/local/sbin
[ 4] Directory for system apps:         /usr/local/sbin
[ 5] Directory for manual pages:        /usr/local/man
[ 7] Directory for spooling:            /var/spool/hylafax
[ 8] Directory for uucp lock files:     /var/lock
[ 9] Uucp lock file scheme:             ascii
[10] PostScript imager package:         gs
[11] PostScript imager program:         /usr/bin/gs
[12] Manual page installation scheme:   bsd-source-cat
[13] Default page size:                 ISO A4
[14] Default vertical res (lpi):        196
確認してから、yesを入力する。
Are these ok [yes]?yes
さらに、パラメーターリストが現れるが、これは変更せずにyesを入力する。
HylaFAX configuration parameters (part 2 of 2) are:

[15] Location of getty program:         /sbin/agetty
[16] Location of voice getty program:   /sbin/vgetty
[17] Location of sendmail program:      /usr/sbin/sendmail
[18] Location of TIFF tools:            /usr/bin
[19] Location of SysV init scripts:     /etc/rc.d/init.d
[20] Location of SysV start scripts:    ../rc2.d ../rc3.d ../rc4.d ../rc5.d
[21] Location of SysV stop scripts:     ../rc0.d ../rc1.d ../rc6.d
[22] Name of SysV start script:         S97hylafax
[23] Name of SysV stop script:          K05hylafax
[24] Init script starts faxq:           yes
[25] Init script starts hfaxd           yes
[26] Start paging protocol:             no
Are these ok [yes]? yes
(省略)

[root@localhost hylafax-6.0.5]# make
[root@localhost hylafax-6.0.5]# make install



◇初期設定を行う

[root@localhost hylafax-6.0.5]# /usr/local/sbin/faxsetup
(略)
Country code [1]? 81 ←日本
Area code []? xx ←日本国内の市外局番から0を除いたもの
Long distance dialing prefix [1]? 0 ←日本での場合は0
International dialing prefix [011]? 010 ←環境に適当なものを入力
(略)
Do you want to run faxaddmodem to configure a modem [yes]? no

Done verifying system setup.
この内容は、/var/spool/hylafax/etc/config というファイルに保存されていた。


ソースからコンパイル作業を行ったiaxmodem-1.2.0 ディレクトリから、IAXmodem用のconfigの原型を持ってくる。
これがなければ、たとえば送出したファックスにタグ(ヘッダー)を付けられなかった。
[root@localhost iaxmodem-1.2.0]# cp -p ./config.ttyIAX /var/spool/hylafax/etc/config.ttyIAX


ファックスのFromタグに表示させる名称を、必要に応じて編集しておく。(ただし英数字のみ可)
[root@localhost ~]# vim /var/spool/hylafax/etc/config.ttyIAX
CountryCode:            81
AreaCode:               xx
FAXNumber:              +81.xxx.xxx.xxx
LongDistancePrefix:     0
InternationalPrefix:    xxx
DialStringRules:        etc/dialrules
ServerTracing:          0xFFF
SessionTracing:         0xFFF
RecvFileMode:           0600
LogFileMode:            0600
DeviceMode:             0600
RingsBeforeAnswer:      1
SpeakerVolume:          off
GettyArgs:              "-h %l dx_%s"
LocalIdentifier:        "example Co.Ltd."  ←ファックス送信元情報
TagLineFont:            etc/lutRS18.pcf
TagLineFormat:          "From %%l %%n   |%c   Page %%P of %%T"  ←ファックスヘッダーのフォーマット(意味は下に記載)
MaxRecvPages:           200
#
(以下省略)
ファックスヘッダーフォーマットで使われている記号の意味
%%l  ・・・LocalIdentifier項目の値
%%n ・・・FAXNumber項目の値
%c ・・・現在の日時
| ・・・ファックス文書のヘッダー領域を左右に均等に区分するもの(上の例では、二分される)


ロケールを英語に切り替える(ファックス文書に印字される日本語の日付が文字化けするため
[root@localhost ~]# date
2011年  9月 26日 月曜日 19:14:05 JST  ←初めはこのように日本語で表記されていた
[root@localhost ~]# cat /etc/sysconfig/i18n
LANG="ja_JP.UTF-8"  ←変数の値は、書き換え前このようになっていた
[root@localhost ~]# vim /etc/sysconfig/i18n
LANG="en_US.UTF-8"
[root@localhost ~]# date
Mon Sep 26 19:18:18 JST 2011  ←再起動後に英語表記に切り替わった(再起動はあとで)



◇システム起動時に、必要なプロセスが始動するように設定を行う

Hylafaxのfaxgettyというプログラムに、iaxmodemモデムに繋がる/dev/ttyIAXを渡す。

/etc/rc.local に、/usr/local/sbin/faxgetty /dev/ttyIAX を記述する方法と、
inittabを使う方法がある。いずれかの方法で設定すればよい。


[root@localhost hylafax-6.0.5]# vim /etc/rc.local
最後の行に追加する。
/usr/local/sbin/faxgetty /dev/ttyIAX

あるいは、次のようにする。
[root@localhost hylafax-6.0.5]# vim /etc/inittab
# Run gettys in standard runlevels
(略)
# Run iaxmodem in standard runlevels
im1:2345:respawn:/usr/local/sbin/iaxmodem ttyIAX
# Run faxgetty in standard runlevels
imh1:2345:respawn:/usr/local/sbin/faxgetty /dev/ttyIAX

(略)

[注意]
このfaxgettyの行は、iaxmodemの行の後に追加すること。引数/dev/ttyIAXが、iaxmodemにより設定ファイルに基づいて生成されるからである。



◇システム起動時にhylafaxが自動起動されるように設定する

 [root@localhost hylafax-6.0.5]# chkconfig hylafax on



◇iaxmodemなど必要なプロセスと共にhylafaxを起動させる

システム再起動後、全てが連動する。
[root@localhost hylafax-6.0.5]# reboot


以上でインストール作業の完了



■動作チェック■

【FAXの送信】

sendfaxコマンドを使ってfaxを送信しようとすると次のようなエラーが出て失敗した。

[root@localhost ~]# sendfax -n -d 電話番号 テキストファイル
/usr/local/sbin/textfmt: No font metric information found for "Courier-Bold".(略)
しかし、クライアントソフトウェアのWinPrint HylaFaxを使ってHylaFaxサーバーへアクセスすると、正常にfaxを送ることができた

WinPrint Hylafaxは、Windowsのプリンタデバイスのように振舞うクライアントソフトウェアである。
文書を扱う適当なWindowsのアプリで「印刷」実行するだけで、Hylafaxサーバーに文書の送出を指示し、任意の宛先へFAXを送ることができる。

この場合、次のように送出される。

Windowsアプリ⇒ WinPrint Hylafax⇒ Hylafax⇒ IAXmodem⇒ ASTERISK⇒ 電話回線

WinPrint Hylafaxの設定については、こちらのリンクを参考
http://akira-arets.blogspot.com/2011/09/ms-windows7-winprint-hylafaxfax.html


◇送信中には、ASTERISKのCLIには、次のようなメッセージが表示された
asterisk-01*CLI>
    -- Accepting AUTHENTICATED call from 192.168.yyy.zzz:
       > requested format = slin,
       > requested prefs = (),
       > actual format = ulaw, ←双方で使うコーデックとしてulawが選択されている
       > host prefs = (ulaw|slin),
       > priority = mine
    -- Executing・・・(省略)・・・
たとえばiaxmodem側とasterisk側で共にulawが使われている場合、コーデックの変換はなく、そして次に説明するPLCは用いられない。(ulawとalawの組み合わせでも問題ない)
音声FAX通信ではPLCが生じていないことは大切である。

PLCとは、パケットがロスしたときにそれがわからないよう無音を挿入するための機能である。
音声を使うFAX通信では、パケットロス時にPLCによって無音が挿入されるとうまく通信ができなくなってしまう。
通信中に20msの無音に遭遇するとFAXモデムは"carrier loss"を検出するからだ。
"carrier loss"は、FAXプロトコルでは次の手順に移るという意味を持っているため通信は失敗してしまう。

FAX送信でエラーが頻発する場合、asteriskを含めた相手先のアナログ電話への経路途中で、PLCが発生していないことを確かめる必要があるだろう

(参考)
・Asterisk IAXmodem < http://www.voip-info.org/wiki/view/Asterisk+IAXmodem > 2011/10/30
・Member "asterisk-1.6.2.20/doc/tex/plc.tex" of archive asterisk-1.6.2.20.tar.gz:
< http://fossies.org/unix/misc/asterisk-1.6.2.20.tar.gz:a/asterisk-1.6.2.20/doc/tex/plc.tex > 2011/10/30


【FAXの受信】

◇ASTERISKのextensions.confに、fax着信用のコンテクストとエクステンションを追加する
[root@asterisk asterisk]# vim /etc/asterisk/extensions.conf
[fax_incoming]

exten => incoming-fax,1,Dial(IAX2/iaxmodem)
当然、この例では、
外線から着信するデバイスの設定で、着信先コンテクストにはfax_incomingを指定し、
さらに、registerステートメントで、着信先エクステンションとしてincoming-faxを指定する必要がある。

◇外線からhylafaxへFAXを送信する

外線からFAX機などを使って文書を送信し、コンテクストfax-incomingのエクステンションincoming-faxに着信させると、
iaxmodemにダイヤルされ、hylafax側でiaxmodemが応答しfaxが受信される。


hylafaxの受信用ディレクトリを確認する
[root@localhost ~]# ls /var/spool/hylafax/recvq/
fax000000006.tif
このように、インデックスがつけられてtif形式で画像ファイルとしてFAXは保存される。

2010年5月17日月曜日

【Linux CentOS5.4】 hylafax-IAXmodem-Asteriskの連携によるFAX送受信の準備

(これは古い情報です。)

CentOSバージョン5.7に、iaxmodem-1.2.0と、hylafax-6.0.5をインストールする新しい手順は、こちらです。
http://akira-arets.blogspot.com/2011/09/linux-centos56-iaxmodemhylafax.html


◆hylafax-IAXmodem-Asteriskの連携によるFAX送受信の準備


■インストールのための下準備・・・

[root@localhost]# yum clean all 
[root@localhost]# yum update -y

[root@localhost]# yum install gcc gcc-c++


■IAXmodemインストールのための準備
[root@localhost]# yum info libjpeg libjpeg-devel libtiff libtiff-devel
Loaded plugins: fastestmirror, kmod
Loading mirror speeds from cached hostfile
 * addons: ftp.yz.yamagata-u.ac.jp
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: ftp.yz.yamagata-u.ac.jp
Installed Packages
Name       : libjpeg
Arch       : i386
Version    : 6b
Release    : 37
Size       : 267 k
Repo       : installed
Summary    : JPEG 画像形式のファイルを操作するためのライブラリ
URL        : http://www.ijg.org/
License    : distributable
Description: The libjpeg package contains a library of functions for manipulating
           : JPEG images, as well as simple client programs for accessing the
           : libjpeg functions.  Libjpeg client programs include cjpeg, djpeg,
           : jpegtran, rdjpgcom and wrjpgcom.  Cjpeg compresses an image file into
           : JPEG format.  Djpeg decompresses a JPEG file into a regular image
           : file.  Jpegtran can perform various useful transformations on JPEG
           : files.  Rdjpgcom displays any text comments included in a JPEG file.
           : Wrjpgcom inserts text comments into a JPEG file.

Name       : libtiff
Arch       : i386
Version    : 3.8.2
Release    : 7.el5_3.4
Size       : 723 k
Repo       : installed
Summary    : TIFF 形式画像ファイルを操作するための関数のライブラリ
URL        : http://www.remotesensing.org/libtiff/
License    : libtiff
Description: The libtiff package contains a library of functions for manipulating
           : TIFF (Tagged Image File Format) image format files.  TIFF is a widely
           : used file format for bitmapped images.  TIFF files usually end in the
           : .tif extension and they are often quite large.
           :
           : The libtiff package should be installed if you need to manipulate TIFF
           : format image files.

Available Packages
Name       : libjpeg-devel
Arch       : i386
Version    : 6b
Release    : 37
Size       : 105 k
Repo       : base
Summary    : libjpeg ライブラリを使用するプログラム用の開発ツール
URL        : http://www.ijg.org/
License    : distributable
Description: The libjpeg-devel package includes the header files and static libraries
           : necessary for developing programs which will manipulate JPEG files using
           : the libjpeg library.
           :
           : If you are going to develop programs which will manipulate JPEG images,
           : you should install libjpeg-devel.  You'll also need to have the libjpeg
           : package installed.

Name       : libtiff-devel
Arch       : i386
Version    : 3.8.2
Release    : 7.el5_3.4
Size       : 465 k
Repo       : base
Summary    : libtiff ライブラリを使用するプログラム用の開発ツール
URL        : http://www.remotesensing.org/libtiff/
License    : libtiff
Description: This package contains the header files and documentation necessary for
           : developing programs which will manipulate TIFF format image files
           : using the libtiff library.
           :
           : If you need to develop programs which will manipulate TIFF format
           : image files, you should install this package.  You'll also need to
           : install the libtiff package.

[root@localhost]# yum install libjpeg libjpeg-devel libtiff libtiff-devel
Complete!
[root@localhost libiax2]# yum install ghostscript ghostscript-devel ghostscript-fonts sox
Complete!


■IAXmodemソースをダウンロードし、インストールする

[root@localhost iaxmodem]# wget http://downloads.sourceforge.net/projec/iaxmodem/iaxmodem/iaxmodem-1.2.0/iaxmodem-1.2.0.tar.gz
長さ: 3075769 (2.9M) [application/x-gzip]
2010-05-17 02:06:19 (1.17 MB/s) - `iaxmodem-1.2.0.tar.gz' へ保存完了 [3075769/3075769]

[root@localhost iaxmodem]# tar zxvf iaxmodem-1.2.0.tar.gz

□ライブラリのインストール
[root@localhost iaxmodem]# cd iaxmodem-1.2.0/lib/libiax2
[root@localhost libiax2]# ./configure
[root@localhost libiax2]# make
[root@localhost libiax2]# make install
Libraries have been installed in:
   /usr/local/lib   →ライブラリがこのディレクトリに生成
□ 生成されたライブラリが入っているディレクトリへのリンクを作成

[root@localhost libiax2]# echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
[root@localhost spandsp]# /sbin/ldconfig -v
/usr/lib/qt-3.3/lib:
        libqui.so.1 -> libqui.so.1.0.0
        libqt-mt.so.3 -> libqt-mt.so.3.3.6
/usr/local/lib:
        libiax.so.0 -> libiax.so.0.0.0

□もうひとつインストールする
[root@localhost libiax2]# cd ..
[root@localhost lib]# cd
libiax2/ spandsp/
[root@localhost lib]# cd spandsp/
[root@localhost spandsp]# ./configure
[root@localhost spandsp]# make install

□本体のインストール
[root@localhost spandsp]# cd ..
[root@localhost lib]# cd ..
[root@localhost iaxmodem-1.2.0]# ./build
[root@localhost iaxmodem-1.2.0]# cp -p iaxmodem /usr/local/sbin/  ・・・生成されたプログラムを適当な場所へコピー


[root@localhost iaxmodem-1.2.0]# mkdir /etc/iaxmodem   ・・・設定ファイルを置くディレクトリの作成
[root@localhost iaxmodem-1.2.0]# ls
CHANGES      TODO     config.ttyIAX        iaxmodem.1            iaxmodem.init.fedora
FAQ          VERSION  configure            iaxmodem.c            iaxmodem.init.suse
Makefile.in  build    iaxmodem             iaxmodem.inf          lib
README       compat   iaxmodem-cfg.ttyIAX  iaxmodem.init.debian  termpkg-ttydforfax.patch
[root@localhost iaxmodem-1.2.0]# cp -p iaxmodem-cfg.ttyIAX /etc/iaxmodem/ttyIAX ・・・設定ファイルをコピー


□デフォルト設定ファイルの確認
[root@localhost iaxmodem-1.2.0]# cat /etc/iaxmodem/ttyIAX
device          /dev/ttyIAX
owner           uucp:uucp
mode            660
port            4570
refresh         300
server          127.0.0.1
peername        iaxmodem
secret          password
cidname         John Doe
cidnumber       8005551212
codec           slinear
★もし、複数のIAXmodemをインスタンス化したいなら、
必要なインスタンス数分、名前を変えて上のコンフィギュレーションファイルをコピーし、
さらに、それぞれ区別できるよう内容を書き換える。
下にあげた二項目については、各互いに異なるように設定する。
device          /dev/ttyIAX ←ttyIAX_01などのように異なる番号をつけ区別する
peername        iaxmodem ←ASTERISKのiax.confの[デバイス定義]と1対1の関係にあるようにする

これらの設定は、IAXmodemが起動されたときに反映される。

□自動起動させるための設定

[root@localhost iaxmodem-1.2.0]# cp -p iaxmodem.init.fedora /etc/init.d/iaxmodem
[root@localhost iaxmodem-1.2.0]# chmod +x /etc/init.d/iaxmodem
[root@localhost iaxmodem-1.2.0]# chkconfig --add iaxmodem
[root@localhost iaxmodem-1.2.0]# chkconfig iaxmodem on
[root@localhost iaxmodem-1.2.0]# chkconfig --list | grep iaxmodem
iaxmodem        0:off   1:off   2:on    3:on    4:on    5:on    6:off

□ログ用ファイルを置く
[root@localhost iaxmodem-1.2.0]# mkdir /var/log/iaxmodem
[root@localhost iaxmodem-1.2.0]# touch /var/log/iaxmodem/iaxmodem


□IAXmodemを起動する
[root@localhost iaxmodem-1.2.0]# service iaxmodem start
IAXmodem を起動中:                                         [  OK  ]
[root@localhost iaxmodem-1.2.0]# ls /dev/ | grep ttyIAX
ttyIAX    ・・・デバイスが作成されている
★前述したように複数のIAXmodemがインスタンス化されるように設定した場合は、
ここで異なる名前の複数のデバイスを見ることになる。



■hylafaxのインストール

○必要なモノをインストールしておく
[root@localhost iaxmodem-1.2.0]# yum install mgetty-voice  ・・・vgettyというプログラムがインストールされる
=============================================================================================================
 Package                      Arch                 Version                        Repository            Size
=============================================================================================================
Installing:
 mgetty-voice                 i386                 1.1.33-9.fc6                   base                 446 k

Transaction Summary
=============================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 446 k
Is this ok [y/N]: y
Downloading Packages:
mgetty-voice-1.1.33-9.fc6.i386.rpm                                                    | 446 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : mgetty-voice                                                                          1/1

Installed:
  mgetty-voice.i386 0:1.1.33-9.fc6
[root@localhost iaxmodem-1.2.0]# ls /sbin/vgetty  ・・・インストールされたvgettyのパスを確認する
/sbin/vgetty

[root@localhost hylafax-6.0.4]# yum install zlib-devel  ・・・これがなければconfigureでエラーが出る

○hylafaxのソースをダウンロードしてインストールする
[root@localhost iaxmodem-1.2.0]# cd ~
[root@localhost ~]# cd tmp
[root@localhost tmp]# mkdir hylafx
[root@localhost tmp]# cd hylafx/
[root@localhost hylafx]# wget ftp://ftp.hylafax.org/source/hylafax-6.0.4.tar.gz
[root@localhost hylafx]# tar xvfz hylafax-6.0.4.tar.gz
[root@localhost hylafx]# cd hylafax-6.0.4
[root@localhost hylafax-6.0.4]# ./configure

質問事項があり、そのうちいくつかを設定しなおす


HylaFAX configuration parameters (part 1 of 2) are:

[ 1] Directory for applications:        /usr/local/bin
[ 2] Directory for lib data files:      /usr/local/lib/fax
[ 3] Directory for lib executables:     /usr/local/sbin
[ 4] Directory for system apps:         /usr/local/sbin
[ 5] Directory for manual pages:        /usr/local/man
[ 7] Directory for spooling:            /var/spool/hylafax
[ 8] Directory for uucp lock files:     /var/lock
[ 9] Uucp lock file scheme:             ascii
[10] PostScript imager package:         gs
[11] PostScript imager program:         /usr/bin/gs
[12] Manual page installation scheme:   bsd-source-cat
[13] Default page size:                 North American Letter
[14] Default vertical res (lpi):        98

Are these ok [yes]? 13
Default page size [North American Letter]? A4

HylaFAX configuration parameters (part 1 of 2) are:

[ 1] Directory for applications:        /usr/local/bin
[ 2] Directory for lib data files:      /usr/local/lib/fax
[ 3] Directory for lib executables:     /usr/local/sbin
[ 4] Directory for system apps:         /usr/local/sbin
[ 5] Directory for manual pages:        /usr/local/man
[ 7] Directory for spooling:            /var/spool/hylafax
[ 8] Directory for uucp lock files:     /var/lock
[ 9] Uucp lock file scheme:             ascii
[10] PostScript imager package:         gs
[11] PostScript imager program:         /usr/bin/gs
[12] Manual page installation scheme:   bsd-source-cat
[13] Default page size:                 ISO A4
[14] Default vertical res (lpi):        98

Are these ok [yes]? 14
Default vertical res (lpi) [98]? 196

HylaFAX configuration parameters (part 1 of 2) are:

[ 1] Directory for applications:        /usr/local/bin
[ 2] Directory for lib data files:      /usr/local/lib/fax
[ 3] Directory for lib executables:     /usr/local/sbin
[ 4] Directory for system apps:         /usr/local/sbin
[ 5] Directory for manual pages:        /usr/local/man
[ 7] Directory for spooling:            /var/spool/hylafax
[ 8] Directory for uucp lock files:     /var/lock
[ 9] Uucp lock file scheme:             ascii
[10] PostScript imager package:         gs
[11] PostScript imager program:         /usr/bin/gs
[12] Manual page installation scheme:   bsd-source-cat
[13] Default page size:                 ISO A4
[14] Default vertical res (lpi):        196

Are these ok [yes]?

HylaFAX configuration parameters (part 2 of 2) are:

[15] Location of getty program:         /sbin/agetty
[16] Location of voice getty program:   /bin/vgetty
[17] Location of sendmail program:      /usr/sbin/sendmail
[18] Location of TIFF tools:            /usr/bin
[19] Location of SysV init scripts:     /etc/rc.d/init.d
[20] Location of SysV start scripts:    ../rc2.d ../rc3.d ../rc4.d ../rc5.d
[21] Location of SysV stop scripts:     ../rc0.d ../rc1.d ../rc6.d
[22] Name of SysV start script:         S97hylafax
[23] Name of SysV stop script:          K05hylafax
[24] Init script starts faxq:           yes
[25] Init script starts hfaxd           yes
[26] Start paging protocol:             no
Are these ok [yes]? 16
Location of vgetty program [/bin/vgetty]? /sbin/vgetty  ・・・vgettyのパス設定(前述)

HylaFAX configuration parameters (part 2 of 2) are:

[15] Location of getty program:         /sbin/agetty
[16] Location of voice getty program:   /sbin/vgetty
[17] Location of sendmail program:      /usr/sbin/sendmail
[18] Location of TIFF tools:            /usr/bin
[19] Location of SysV init scripts:     /etc/rc.d/init.d
[20] Location of SysV start scripts:    ../rc2.d ../rc3.d ../rc4.d ../rc5.d
[21] Location of SysV stop scripts:     ../rc0.d ../rc1.d ../rc6.d
[22] Name of SysV start script:         S97hylafax
[23] Name of SysV stop script:          K05hylafax
[24] Init script starts faxq:           yes
[25] Init script starts hfaxd           yes
[26] Start paging protocol:             no
Are these ok [yes]?


Done.
[root@localhost hylafax-6.0.4]# make     ・・・時間がかかる(5分近く)
[root@localhost hylafax-6.0.4]# make install


○セットアップを行う
[root@localhost hylafax-6.0.4]#/usr/local/sbin/faxsetup

・・・yumをつかってhylafaxをインストールしていたためか、なぜか特にせっていすることなく終了


○コンフィグファイルを確認する
[root@localhost hylafax-6.0.4]# cat /var/spool/hylafax/etc/config
LogFacility:            daemon
CountryCode:            81
AreaCode:               ** ←市外局番から先頭の0をとったものを入れる
LongDistancePrefix:     0
InternationalPrefix:    010 ←国際電話用
DialStringRules:        etc/dialrules
ServerTracing:          1
○ソースを展開しコンパイル作業を行った iaxmodem-1.2.0 ディレクトリから、
IAXmodemを使うための prototype configを持ってくる
[root@localhost iaxmodem-1.2.0]# cp -p ./config.ttyIAX /var/spool/hylafax/etc/config.ttyIAX

★複数のIAXmodemモデムをhylafaxで使うには、
それぞれのIAXmodemが持っている互いに異なるデバイス名を用いてprototype configをコピーすること。
(例)ttyIAX_01とリンクしたmodemに対して、hylafaxの設定ファイルは、/var/spool/hylafax/etc/config.ttyIAX_01とする。

[root@localhost hylafax-6.0.4]# vi /var/spool/hylafax/etc/config.ttyIAX ←モデムがつながったデバイスの名称
# $Id: iaxmodem,v 1.7 2007/11/06 18:44:20 faxguy Exp $

#
# prototype config for the IAXmodem softmodem which uses
# the spandsp soft-DSP library
#

#
CountryCode:            81 ←国際電話での国番号(日本)
AreaCode:               ** ←市外局番から先頭の0をとった番号
FAXNumber:              +81.**.***.**** ←ファックス番号(自局)
LongDistancePrefix:     0
InternationalPrefix:    010  ←国際電話発信用番号
DialStringRules:        etc/dialrules
ServerTracing:          1
SessionTracing:         0xFFF
RecvFileMode:           0600
LogFileMode:            0600
DeviceMode:             0600
RingsBeforeAnswer:      1
SpeakerVolume:          off
GettyArgs:              "-h %l dx_%s"
LocalIdentifier:        ***  ←自局の名称
TagLineFont:            etc/lutRS18.pcf
TagLineFormat:          "From %%l|%c|Page %%P of %%T"
MaxRecvPages:           25
#

#
#
# Modem-related stuff: should reflect modem command interface
# and hardware connection/cabling (e.g. flow control).
#
ModemType:              Class1          # use this to supply a hint

#
#             *** Caller-ID settings ***
#
# Enabling this will use the hfaxd-protocol to set Caller*ID
#
#ModemSetOriginCmd:     "AT+VSID=\"%s\",\"%d\""
#
# If "glare" during initialization becomes a problem then take
# the modem off-hook during initialization, and then place it
# back on-hook when done.
#
#ModemResetCmds:        "ATH1\nAT+VCID=1"       # enables CallID display
#ModemReadyCmds:        ATH0
#
# You'll likely want Caller*ID display (also displays DID) enabled.
#
ModemResetCmds:         AT+VCID=1       # enables CallID display
#
# If you are "missing" Caller*ID data on some calls (but not all)
# and if you do not have adequate glare protection you may want to
# not answer based on RINGs, but rather enable the CallIDAnswerLength
# for NDID, disable AT+VCID=1 and do this:
#
#RingsBeforeAnswer: 0
#ModemRingResponse: AT+VRID=1

# The pty apparently does not support changing parity.
PagerTTYParity:         none

Class1AdaptRecvCmd:     AT+FAR=1
Class1TMConnectDelay:   400             # counteract quick CONNECT response

#
# Older iaxmodem versions didn't support V.17 very well.  It can be
# disabled in this fashion:
#
#Class1RMQueryCmd:      "!24,48,72,96"  # V.17 fast-train recv doesn't work well
#Class1TMQueryCmd:      "!24,48,72,96"  # V.17 fast-train recv doesn't work well

CallIDPattern:          "NMBR="
CallIDPattern:          "NAME="
CallIDPattern:          "ANID="
CallIDPattern:          "NDID="
#CallIDAnswerLength:    4
# Uncomment these if you really want them, but you probably don't.
#CallIDPattern:          "DATE="
#CallIDPattern:          "TIME="


○hylafaxを自動起動させる
[root@localhost hylafax-6.0.4]# chkconfig hylafax on
[root@localhost hylafax-6.0.4]# chkconfig --list | grep hyla
hylafax         0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@localhost hylafax-6.0.4]# service hylafax restart
Stopping HylaFAX Servers.
HylaFAX: faxq hfaxd (without SNPP support).


○ttyIAXデバイスをfaxgetty(hylafaxに添付されている)に渡す
これをやらなければ、hylafaxがFAXを受信しなかった。
[root@localhost ~]# /usr/local/sbin/faxgetty /dev/ttyIAX &
[1] 3591

★複数のmodemがhylafaxに接続されるなら、各modemのデバイスを同様にfaxgettyに渡す

○ 状態を表示する
[root@localhost ~]# faxstat -s
HylaFAX scheduler on localhost.localdomain: Running ←hylafax ready
Modem ttyIAX (+81.**.***.****): Initializing server  ←Modem ttyIAX  サーバーを初期化中

[root@localhost ~]# faxstat -s
HylaFAX scheduler on localhost.localdomain: Running ←hylafax ready
Modem ttyIAX (+81.**.***.****): Running and idle  ←Modem ttyIAX ready

IAXmodemと、hylafaxの準備は以上で完了



◆試しにhylafaxからファックスを送信してみる 


すでにASTERISKはインストール済みで、外線へのアクセスも可能になっている状態にしておく。
IAXmodemがASTERISKにレジストするので、そのためのデバイスを iax.conf に定義する。


○ASTERISKを設定する

IAXmodemが持つ設定情報は次のとおり。
[root@localhost iaxmodem-1.2.0]# cat /etc/iaxmodem/ttyIAX
device          /dev/ttyIAX
owner           uucp:uucp
mode            660
port            4570
refresh         300
server          127.0.0.1
peername        iaxmodem
secret          password
cidname         John Doe
cidnumber       8005551212
codec           slinear
上の情報に合うように、ASTERISK設定ファイルのiax.confを編集する
[general]
iaxcompat=yes
language=jp
bandwidth=medium
disallow=all
allow=ulaw
allow=slinear
jitterbuffer=no
forcejitterbuffer=no

[iaxmodem]
type=friend
username=iaxmodem
secret=password
host=dynamic
disallow=all
allow=ulaw
allow=slinear
requirecalltoken=no
context=外線につなげられるコンテクスト

IAXmodemからの呼が設定済みの適当なデフォルトコンテクストへ流れるように設定する。

○IAXmodemと、ASTERISKとの接続を確認する
localhost*CLI> iax2 show peers
Name/Username    Host                 Mask             Port          Status
iaxmodem/iaxmod  127.0.0.1       (D)  255.255.255.255  4570          Unmonitored  ・・・接続された


○上記のように準備が整っていたら、テキストファイルをファクス送信する

[root@localhost ~]# sendfax -n -d デンワ番号  送信するテキストファイル
request id is 1 (group id 1) for host localhost (1 file)

[root@localhost ~]# faxstat -s
HylaFAX scheduler on localhost.localdomain: Running
Modem ttyIAX (+81.**.***.****): Initializing server

JID  Pri S  Owner Number       Pages Dials     TTS Status
1    127 R   root 0*********    0:1   0:12


数十秒後、電話がかかってきました!
そして、指定したテキストファイルがファックス機で印字されてきました。
やっとできた。

○送信済みの処理を表示させる
[root@localhost ~]# faxstat -d
HylaFAX scheduler on localhost.localdomain: Running
Modem ttyIAX (+81.**.***.****): Running and idle

JID  Pri S  Owner Number       Pages Dials     TTS Status
1    127 D   root 0*********    1:1   1:12


<参考>
http://n73.jugem.jp/?eid=10
http://blog.goo.ne.jp/jnana_tomo/e/123f1557e1d3303d15e358f7ed92d3fb


◆ついでに、WINDOWSからファックスを送ってみる

WindowsXPを使用して、hylafax経由でファクスを送る

○リモート接続を許可する、登録済みのリナックスuserをセットする。(当然パスワード設定済み)
[root@localhost hylafax-6.0.4]# faxadduser username


Windowsマシンで作業を行う
○Winprint HylaFAXをダウンロード、インストールを行う


http://www.hylafax.org/content/Related_Software内のリンクに、
http://www.hylafax.org/content/Desktop_Client_Softwareがある。
Winprint HylaFAX: A simple-to-use Windows printer client (2008)をダウンロードし、実行する
インストール終了後は何も表示されない

○プリンタの追加

「プリンタとFAXの追加」で、「プリンタの追加」をクリック
ローカルプリンタを指定

新しいポートの作成(→Winprint HylaFAXを指定する)
PortNameには最初は、HFAX1: が入力されている。(キュー名みたいな識別子なので何でもよい)

プリンタドライバの選択画面で、Appleを選ぶ
ドライバは、LaserWriter 16/600 PS-J を指定する(ポストスクリプトプリンタのこと)

設定したプリンターのプロパティーから「ポートの構成」を開く
HylaFAX Server Addressには、リナックスマシンのアドレスを入力
Usernameと、Passwordは上で設定したものを入力
Address Book Directoryは、アドレスを貯めるファイルをおくディレクトリなので勝手に作って指定する(c:\hylafaxとした)
Page Sizeはデフォルトの用紙の大きさ (A4にした)

○上で指定したAddress Book Directoryにファイルを2つ作成する
c:\hylafax(上の例で)に、names.txt と、numbers.txtという名称の空ファイルを作成しておく


以上で準備完了。


○テストプリントする
あて先のFAX番号を入れて(Save Numberボタンで保存することもできる)、 Sendボタンを押すだけ
Save Numberボタンで保存したものは、Delete Entryボタンで消すことも可能。

送信ボタンを押下直後に、
Job x Submitted という文が書かれた小さなウインドウが開くと同時に処理が進めれる


数秒後、着信しファックスが届いた。

<参考>
http://winprinthylafax.sourceforge.net/


◆FAXを受信する

○ASTERISKでの着信用設定
ASTERISKにおいて、外線からの着信が[fax]コンテクストのエクステンション20に入ってくるとする。

[fax]
exten => 20,1,Dial(IAX2/iaxmodem)   ・・・iaxmodemはiax.confで定義したもの(前述)


○faxgettyに、ttyIAXが渡されていることを確認する
[root@localhost asterisk]# faxstat
HylaFAX scheduler on localhost.localdomain: Running
Modem ttyIAX (+81.**.***.****: Running and idle

渡されていなければ、次のようにコマンドを実行する(前述)
[root@localhost asterisk]# /usr/local/sbin/faxgetty /dev/ttyIAX &


○hylafaxへファックスを送信する

○スプールを確認する
[root@localhost asterisk]# ls /var/spool/hylafax/recvq/
fax000000002.tif  seqf

○受信したファックス文書をpdfファイルに変換し電子メールで送る
[root@localhost asterisk]# vi /var/spool/hylafax/etc/FaxDispatch
SENDTO=me@my.mail.server;
FILETYPE=pdf;

Ad

Ad