Mit der Gemeinschaft 5 TK-Anlage und einem HP Enterprise Oll-In-One Laserdrucker lassen auch FAXe vom Drucker aus verschicken. Dazu muss auf der GS5 Installation lediglich der proftpd aus dem Debian Repository installiert werden.
/etc/proftpd/proftpd.conf
Die proftpd.conf soll nur authentifizierte User rein lassen, daher muss an der Debian Default nicht geändert werden.
#
# /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file.
# To really apply changes, reload proftpd after modifications, if
# it runs in daemon mode. It is not required in inetd/xinetd mode.
#
# Includes DSO modules
Include /etc/proftpd/modules.conf
# Set off to disable IPv6 support which is annoying on IPv4 only boxes.
UseIPv6 on
# If set on you can experience a longer connection delay in many cases.
IdentLookups off
ServerName "Debian"
ServerType standalone
DeferWelcome off
MultilineRFC2228 on
DefaultServer on
ShowSymlinks on
TimeoutNoTransfer 600
TimeoutStalled 600
TimeoutIdle 1200
DisplayLogin welcome.msg
DisplayChdir .message true
ListOptions "-l"
DenyFilter \*.*/
# Port 21 is the standard FTP port.
Port 21
MaxInstances 30
# Set the user and group that the server normally runs at.
User proftpd
Group nogroup
# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask 022 022
# Normally, we want files to be overwriteable.
AllowOverwrite on
# Uncomment this if you are using NIS or LDAP via NSS to retrieve passwords:
# PersistentPasswd off
# This is required to use both PAM-based authentication and local passwords
# AuthOrder mod_auth_pam.c* mod_auth_unix.c
# Be warned: use of this directive impacts CPU average load!
# Uncomment this if you like to see progress and transfer rate with ftpwho
# in downloads. That is not needed for uploads rates.
#
# UseSendFile off
TransferLog /var/log/proftpd/xferlog
SystemLog /var/log/proftpd/proftpd.log
# Logging onto /var/log/lastlog is enabled but set to off by default
#UseLastlog on
# In order to keep log file dates consistent after chroot, use timezone info
# from /etc/localtime. If this is not set, and proftpd is configured to
# chroot (e.g. DefaultRoot or <Anonymous>), it will use the non-daylight
# savings timezone regardless of whether DST is in effect.
#SetEnv TZ :/etc/localtime
<IfModule mod_quotatab.c>
QuotaEngine off
</IfModule>
<IfModule mod_ratio.c>
Ratios off
</IfModule>
# Delay engine reduces impact of the so-called Timing Attack described in
# http://www.securityfocus.com/bid/11430/discuss
# It is on by default.
<IfModule mod_delay.c>
DelayEngine on
</IfModule>
<IfModule mod_ctrls.c>
ControlsEngine off
ControlsMaxClients 2
ControlsLog /var/log/proftpd/controls.log
ControlsInterval 5
ControlsSocket /var/run/proftpd/proftpd.sock
</IfModule>
<IfModule mod_ctrls_admin.c>
AdminControlsEngine off
</IfModule>
# Include other custom configuration files
Include /etc/proftpd/conf.d/
Die exec.conf ist der einzige, interessante Teil der proftpd Konfiguration.
/etc/proftpd/conf.d/exec.conf
<IfModule mod_exec.c>
ExecEngine on
ExecLog /var/log/proftpd/exec.log
ExecOnCommand WRITE,APPE,STOR /opt/cftools/hp2fax.pl %f
</IfModule>
Der HP Drucker lädt die FAX Files einfach per ftp hoch, der muss der proftpd nur auf entsprechende Ereignisse reagieren.
/opt/cftools/hp2fax.pl
Dieses Skript macht die eigentliche Arbeit, es analysiert das Meta File vom HP Drucker und schickt auf Basis dieser Daten das FAX raus. Soweit möglich, wird auch T.38 unterstützt.
#!/usr/bin/env perl
use strict;
use File::Basename;
my $DEBUG=0;
my $gateway="gateway5";
my $faxhome="/home/fax";
my $fax_id="+496128****";
my $fax_header="Mein Fax Gerät";
my $fax_options="fax_enable_t38=true,fax_use_ecm=true,fax_enable_t38_request=true";
sub faxReport {
my ($filename,$msg)=@_;
my $logfile="${faxhome}/".basename("$filename",".tif").".log";
open (LOG,">>$logfile") || die "cannot open $logfile for write";
print LOG "$msg\n";
close LOG;
}
sub execCmd {
my ($cmd)=@_;
open (CMD,"$cmd|") || die "cannot exec $cmd";
while (my $line=<CMD>) {
chomp $line;
}
close CMD;
}
sub convert {
my ($filename,$mode)=@_;
my $outfile="${filename}.fax";
my $cmd;
$cmd="tiff2ps -p -a \"${filename}\" -O \"${outfile}.ps\"";
execCmd("$cmd");
my $res="-r204x98";
if ($mode=~/^fine/i) { $res="-r204x196"; }
elsif ($mode=~/^superfine/i) { $res="-r204x392"; }
$cmd="gs -q -dNOPAUSE -dBATCH -sDEVICE=tiffg32d ${res} -sOutputFile=${outfile} \"${outfile}.ps\"";
execCmd("$cmd");
unlink ("${outfile}.ps");
return "${outfile}";
}
sub sendFax {
my ($filename,$mode,$number)=@_;
my $faxfile=convert("$filename",$mode);
if ($DEBUG) { $fax_options.=",fax_verbose=true"; }
my $fs_cmd="originate {fax_ident='${fax_id}',fax_header='${fax_header},${fax_options}'}sofia/gateway/${gateway}/${number} &txfax(${faxhome}/${faxfile})";
my $cmd="fs_cli -x \"${fs_cmd}\"";
faxReport ($filename,"cmd: $cmd");
open (CMD,"$cmd|") || die "cannot exec $cmd";
while (my $line=<CMD>) {
chomp $line;
faxReport ($filename,"freeswitch: $line");
}
close CMD;
}
sub parseMeta {
my ($filename)=@_;
my $dirname=dirname("$filename");
my $hpf;
my $number="";
my $file="";
my $mode="";
open ($hpf,"$filename") || die "cannot open $filename for read";
while (my $line=<$hpf>) {
$line=~s/\r[\n]*//gm;
if ($line=~/##dial\s+(\d+)/) {
$number="$1";
} elsif ($line=~/^##fine\s+(.+)$/) {
$mode="$1";
} elsif ($line=~/^##Filename\s+(.+)$/) {
$file="$1";
}
}
close $hpf;
sendFax ($file,$mode,$number);
}
my ($filename)=@ARGV;
if ($filename=~/^.*\.hpf$/) {
parseMeta("$filename");
}
exit 0;
HP Drucker
Auf dem HP-Drucker muss ein LAN-Fax-Dienst eingerichtet werden, wobei "Auf FTP-Server speichern" die richtige Option ist. Ansonsten sind nur noch die Angaben zum Server, User und Passwort zu machen. Der "FTP-Verzeichnispfad" bleibt leer.
- Anmelden, um Kommentare verfassen zu können