Linux Server

FAXサーバ構築(mgetty+sendfax) CentOS編

  

ご注意下さい

この記事は3年以上前に書かれた記事ですので、内容が古い可能性があります。

0
(0)

CentOS5.5でもFAXサーバを作ってみました。
以前の方法でだいたいOKですが、多少違いがありましたのでその点のみ。

/etc/inittabは以下のように最終行に記載をします。

7:2345:respawn:/sbin/mgetty ttyS0

また、CentOSでは/etc/mgetty+sendfax/new_faxコマンドで利用するmmencodeがありません。以前のnew_faxではなく、/usr/share/doc/mgetty-1.1.33/samples/new_fax.tiff を /etc/mgetty+sendfax/new_faxとしてコピーしパーミッションも755に変更しましょう。
結局 new_fax.tiff中で使っているコマンドのmetasendがCentOSではパッケージされていないため利用を断念。旧来のnew_faxに戻しました。ただし前述の通りmmencodeコマンドがない為base64コマンドに置き換えています。(53,54行目と117,118行目)

#From: Martin Spott <martin@@onyx.dirnet.com>
#Subject: aaaiiiiiaaaaiiiiiii ....
#To: gert@@greenie.muc.de
#Date: Mon, 5 Aug 1996 22:55:24 +0200 (MET DST)


#!/bin/sh
#
# I normally run this with a statically linked '/bin/pdksh'

# /usr/local/lib/mgetty+sendfax/new_fax
#
# A script to send mgetty's incoming faxes via MIME encoded EMail;
# by Martin Spott (martin.spott@@uni-duisburg.de), I borrowed one or two
# lines from other's ....
#
# I wrote this one because I wanted a program using as little specialized
# MIME tools as possible.
#
# This 'new_fax' only needs ' g3topbm', 'pnmscale' and 'pnmtotiff' from the
# 'pbmplus' package, 'mmencode' from the 'multimail' packages, and the rest
# is standard Unix tools.
# It was tested with thsmail under Linux and PMMail under OS/2 as frontends.

# This script is called when a message was recorded.
# It gets the following arguments:
#      $1 : the hangup code
#      $2 : the remote id
#      $3 : the number of pages
#      $4... : the file names

# Place the correct EMail-adresses here !!!
USER="fax"
ADMIN="root"

# How mgetty calls us.
HANGUP_CODE="$1"
SENDER_ID="$2"
NUMBER_PAGES="$3"

# Some miscellaneous data and filenames.
TMP=/tmp
XSCALE=0.58
TIMESTAMP=`/bin/date +%m.%d_%H:%M:%Sh`
MIME_TIFF=$TMP/TIFF_$TIMESTAMP
MIME_MAIL=$TMP/MAIL_$TIMESTAMP

# The binaries we need; please check carefully !!!
BASENAME=/bin/basename
CAT=/bin/cat
ECHO=/bin/echo
ELM=/usr/bin/elm
G3TOPBM=/usr/bin/g3topbm
#MMENCODE=/usr/bin/mmencode
MMENCODE=/usr/bin/base64
PNMSCALE=/usr/bin/pnmscale
PNMTOTIFF=/usr/bin/pnmtotiff
RM=/bin/rm
SED=/bin/sed
SENDMAIL=/usr/sbin/sendmail

# Essential lines to put into the header of a MIME mail.
HEADERLINE_1="MIME-Version: 1.0"
HEADERLINE_2="Content-Type: multipart/mixed; boundary="attachment""

# Lines to put into the header of each MIME attachment.
ATTACHMENT_HEADERLINE_1="--attachment"
ATTACHMENT_HEADERLINE_2="Content-Type: image/tiff"
ATTACHMENT_HEADERLINE_3="Content-Transfer-Encoding: base64"

# Line to close the attachment section of a MIME mail.
ATTACHMENT_ENDLINE="--attachment--"

# Now we build our MIME mailheader using commandline arguments.
$ECHO "Subject: incoming FAX from $2 with $3 pages" > $MIME_MAIL
$ECHO "$HEADERLINE_1" >> $MIME_MAIL
$ECHO "$HEADERLINE_2" >> $MIME_MAIL
$ECHO "" >> $MIME_MAIL

# To handle each attachment we skip the first three arguments (those we
# already used for the header).
shift 3

# Handling of each fax page, whose names are given via commandline arguments.
# We have to cut off the absolute path via 'basename' and remove the dot
# which separates the page number. Also we add a filename extension and fit
# the result as filename into our attachment header - some mail frontends
# need this.
#
for i in $@
do
        # We use the second character in the filename to identify the
        # resolution of our incoming fax, so we can easily scale the fax for
        # display on a screen.
        RESOLUTION=`$BASENAME $i | $SED 's/.\(.\).*/\1/'`
        if [ "$RESOLUTION" = "n" ]
        then
                YSCALE=1.16
        else
                YSCALE=0.58
        fi
#
        # The fax is converted from G3 to PBM, it is scaled and then
        # converted to TIFF.
        # We write it into a temporary file, because my 'mmencode' doesn't
        # handle standard input correctly.
        $CAT $i | $G3TOPBM | $PNMSCALE -xscale $XSCALE -yscale $YSCALE \
        | $PNMTOTIFF -packbits> $MIME_TIFF
#
        # Now we put the header for each attachment into our MIME mail.
        $ECHO "$ATTACHMENT_HEADERLINE_1" >> $MIME_MAIL
        $ECHO "$ATTACHMENT_HEADERLINE_2; name=\"`$BASENAME $i|cut -f1 -d\.``$BASENAME $i|cut -f2 -d \.`.TIF\"" >> $MIME_MAIL
        $ECHO "$ATTACHMENT_HEADERLINE_3" >> $MIME_MAIL
        $ECHO "" >> $MIME_MAIL
#
        # Here we do base64 encoding of out TIFF data and add the result
        # into our MIME mail as attachment.
        #$MMENCODE -b $MIME_TIFF >> $MIME_MAIL
        $MMENCODE < $MIME_TIFF >> $MIME_MAIL
#
        # To clean up temporary TIFF data.
        $RM -f $MIME_TIFF
#
        # Each attachment has to end with a blank line (I believe).
        $ECHO "" >> $MIME_MAIL
done

# To close the attachment section of our mail.
$ECHO "$ATTACHMENT_ENDLINE" >> $MIME_MAIL

# Sending the mail.
$SENDMAIL < $MIME_MAIL $USER

# Cleaning up mail data.
$RM -f $MIME_MAIL

# Cheerio !
exit 0

また、/etc/samba/smb.confも修正が必要です。CentOSなど最近のLinuxからは印刷システムがlpdではなくCUPSに変更になっています。samba経由で印刷する際にはCUPSにデータが渡されてしまいprint commandが効かない為、[global]セクションにcupsを利用しない設定を加えましょう。

;       printing = cups
printing = bsd

最後の/etc/mgetty+sendfax/fax.allowファイルを編集しないとrootユーザしかFAXが送信できません。

root <samba経由でFAXにアクセスするLinuxユーザ名>

とFAX送信可能なユーザを定義しましょう。

これでファックスの送受信が可能になります。
しかし最近はめっきりFAXを利用する機会も減りましたね…。

この記事は役に立ちましたか? | Is this article useful for you?

評価をお願いします | Please leave your rating.

平均 | Av.: 0 / 5. 投票数 | Votes: 0

最初の評価を下さい | Please vote for the first rating.

-Linux Server
-

© 1999 - 2021 蒲田ネット