debian: ทดลองทำ HylaFAX Client
เอามาจาก debian : ทดลองติดตั้ง hylafax
ต้องมีเซิร์ฟเวอร์ที่เป็น HylaFAX แล้ว ดูวิธีติดตั้งได้จากคราวก่อน
ติดตั้ง Pyla
$ sudo aptitude install python python-tk
$ wget http://www.teamsw.it/pyla/download/pyla1.1.7.1.tgz
$ tar xfz pyla1.1.7.1.tgz
$ sudo mv pyla /usr/local
$ /usr/local/pyla/pyla.py
-> ปรับตั้งโปรแกรม
ติดตั้งเครื่องพิมพ์เทียมให้ pyla
เอามาจาก Fun with CUPS and Pyla
หลักการคือเขาใช้ perl เขียนโปรแกรมทำหน้าที่เป็น socket คอยดูว่ามีข้อมูลเข้ามาทางพอร์ต 5691 หรือเปล่า ถ้ามี ก็จะเรียกใช้โปรแกรมนี้ซึ่งจะไปเรียกใช้ pyla อีกทีนึง
สร้างโปรแกรมเรียก pyla ชื่อ pyla-print เอาใส่ไว้ใน /usr/local/bin
$ sudo vi /usr/local/bin/pyla-print
#!/usr/bin/perl
# Daniel E. Markle
# 20031114 Revision 0.1
# This program starts up a daemon which will watch for a postscript file
# coming in from CUPS, then launch pyla to send it as a fax.
# Use it with the socket://localhost:5691 URL in cups.
# Issues:
# -security, make sure only localhost can see this port, it allows anyone
# who can stream data to this port to popup pyla on your desktop
# -must be ran as the user or the window may not pop up at the right
# place, if at all
# ***CONFIGURE ME HERE
# Port to listen on, use socket://localhost: in cups
my $MY_PORT = 5691;
# Temporary file storage, this is a file not a folder
my $TMP_FILE_NAME = "/tmp/cupsfaxtemp";
# Path to pyla.py
my $PYLA_PATH = "/usr/local/pyla/pyla.py";
# Path to python binary
# use this one for Linux
my $PYTHON_PATH = "/usr/bin/python";
# use this one for OS X
#my $PYTHON_PATH = "/usr/bin/pythonw";
# ***END CONFIGURATION
# ----- You shouldn't need to touch anything beyond this point -----
use IO::Socket::INET;
# check to make sure we can use the temp file
open ( TMPFILE, ">", $TMP_FILE_NAME )
or die "Can not open temp file $TMP_FILE_NAME, " .
"check to make sure it is not owned by another user";
close ( TMPFILE );
if ( !(-e $PYLA_PATH) ) {
die "I do not see pyla at $PYLA_PATH";
}
my $data;
my $server = IO::Socket::INET->new (
LocalPort => $MY_PORT,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 1
) or die "Could not start server process";
while ( my $job = $server->accept() ) {
open ( TMPFILE, ">", $TMP_FILE_NAME );
while ( <$job> ) {
print TMPFILE $_;
}
close ( TMPFILE );
close $job;
`cat "$TMP_FILE_NAME" | "$PYTHON_PATH" "$PYLA_PATH" -i`
}
ทำให้รันได้
$ sudo chmod 755 /usr/local/bin/pyla-print
สร้างโปรแกรมที่รันเป็น daemon คอยดูซอกเก็ต ชื่อ pyla-printd เอาใส่ไว้ใน /etc/init.d
$ sudo vi /etc/init.d/pyla-printd
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/pyla-print
NAME=pyla-print
DESC="Pseudo printer for Pyla"
test -x $DAEMON || exit 0
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--oknodo
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--oknodo
sleep 1
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
ทำให้รันได้ - สั่งรันเป็น daemon และให้เริ่มรันทุกครั้งที่เปิดเครื่อง
$ sudo chmod 755 /etc/init.d/pyla-printd
$ sudo /etc/init.d/pyla-printd restart
$ sudo update-rc.d pyla-printd defaults
ติดตั้งตัวจัดการเครื่องพิมพ์
$ sudo aptitude install cupsys-client
เพิ่มเครื่องพิมพ์เทียมให้ระบบ
$ sudo lpadmin -p pseudo-pyla -E -v socket://localhost:5691
หรือตั้งชื่อให้เรียกง่ายขึ้นว่า hylafax เฉย ๆ ก็ได้
$ sudo lpadmin -p hylafax -E -v socket://localhost:5691
เมื่อทุกอย่างเรียบร้อย จะมีเครื่องพิมพ์ฃื่อ psuedo-pyla ขึ้นมา ถ้าเราพิมพ์มาที่เครื่องพิมพ์ตัวนี้ เขาจะมาเรียกใช้ pyla ให้ส่งแฟกซ์เอง
update
- แก้ปัญหาดูแฟกซ์ที่รับไม้ได้
- ตั้งการอนุญาตใช้ไฟล์ ที่ไฟล์โมเด็ม (ส่วนใหญ่จะชื่อ config.ttyS0)
# vi /etc/hylafax/config.ttyS0... RecvFileMode: 0666 ...
- Printer-friendly version
- Log in or register to post comments
- 5109 reads







Recent comments