HP All-In-One Fax -> Gemeinschaft 5

Submitted by admin on Sa, 15.04.2017 - 10:16

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.


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 mod_ratio.c>
Ratios off

# 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 mod_ctrls.c>
ControlsEngine        off
ControlsMaxClients    2
ControlsLog           /var/log/proftpd/controls.log
ControlsInterval      5
ControlsSocket        /var/run/proftpd/proftpd.sock

<IfModule mod_ctrls_admin.c>
AdminControlsEngine off

# Include other custom configuration files
Include /etc/proftpd/conf.d/

Die exec.conf ist der einzige, interessante Teil der proftpd Konfiguration.


<IfModule mod_exec.c>
    ExecEngine on
    ExecLog /var/log/proftpd/exec.log
    ExecOnCommand WRITE,APPE,STOR /opt/cftools/hp2fax.pl %f

Der HP Drucker lädt die FAX Files einfach per ftp hoch, der muss der proftpd nur auf entsprechende Ereignisse reagieren.


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\"";
  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\"";
  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>) {
    if ($line=~/##dial\s+(\d+)/) {
    } elsif ($line=~/^##fine\s+(.+)$/) {
    } elsif ($line=~/^##Filename\s+(.+)$/) {
  close $hpf;
  sendFax ($file,$mode,$number);

my ($filename)=@ARGV;

if ($filename=~/^.*\.hpf$/) {

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.