Archive for the ‘linux’ Category

Backup and restore your system!

Howto: Backup and restore your system!

Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!

Most of you have probably used Windows before you started using Ubuntu. During that time you might have needed to backup and restore your system. For Windows you would need proprietary software for which you would have to reboot your machine and boot into a special environment in which you could perform the backing-up/restoring (programs like Norton Ghost).
During that time you might have wondered why it wasn’t possible to just add the whole c:\ to a big zip-file. This is impossible because in Windows, there are lots of files you can’t copy or overwrite while they are being used, and therefore you needed specialized software to handle this.

Well, I’m here to tell you that those things, just like rebooting, are Windows CrazyThings ™. There’s no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter). In fact; using Ghost might be a very bad idea if you are using anything but ext2. Ext3, the default Ubuntu partition, is seen by Ghost as a damaged ext2 partition and does a very good job at screwing up your data.

1: Backing-up

“What should I use to backup my system then?” might you ask. Easy; the same thing you use to backup/compress everything else; TAR. Unlike Windows, Linux doesn’t restrict root access to anything, so you can just throw every single file on a partition in a TAR file!

To do this, become root with

Code:
sudo su

and go to the root of your filesystem (we use this in our example, but you can go anywhere you want your backup to end up, including remote or removable drives.)

Code:
cd /

Now, below is the full command I would use to make a backup of my system:

Code:
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

Now, lets explain this a little bit.
The ‘tar’ part is, obviously, the program we’re going to use.

‘cvpfz’ are the options we give to tar, like ‘create archive’ (obviously),
‘preserve permissions’(to keep the same permissions on everything the same), and ‘gzip’ to keep the size down.

Next, the name the archive is going to get. backup.tgz in our example.

Next comes the root of the directory we want to backup. Since we want to backup everything; /

Now come the directories we want to exclude. We don’t want to backup everything since some dirs aren’t very useful to include. Also make sure you don’t include the file itself, or else you’ll get weird results.
You might also not want to include the /mnt folder if you have other partitions mounted there or you’ll end up backing those up too. Also make sure you don’t have anything mounted in /media (i.e. don’t have any cd’s or removable media mounted). Either that or exclude /media.

EDIT : kvidell suggests below we also exclude the /dev directory. I have other evidence that says it is very unwise to do so though.

Well, if the command agrees with you, hit enter (or return, whatever) and sit back&relax. This might take a while.

Afterwards you’ll have a file called backup.tgz in the root of your filessytem, which is probably pretty large. Now you can burn it to DVD or move it to another machine, whatever you like!

EDIT2:
At the end of the process you might get a message along the lines of ‘tar: Error exit delayed from previous errors’ or something, but in most cases you can just ignore that.

Alternatively, you can use Bzip2 to compress your backup. This means higher compression but lower speed. If compression is important to you, just substitute
the ‘z’ in the command with ‘j’, and give the backup the right extension.
That would make the command look like this:

Code:
tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

2: Restoring

Warning: Please, for goodness sake, be careful here. If you don’t understand what you are doing here you might end up overwriting stuff that is important to you, so please take care!

Well, we’ll just continue with our example from the previous chapter; the file backup.tgz in the root of the partition.

Once again, make sure you are root and that you and the backup file are in the root of the filesystem.

One of the beautiful things of Linux is that This’ll work even on a running system; no need to screw around with boot-cd’s or anything. Of course, if you’ve rendered your system unbootable you might have no choice but to use a live-cd, but the results are the same. You can even remove every single file of a Linux system while it is running with one command. I’m not giving you that command though!

Well, back on-topic.
This is the command that I would use:

Code:
 tar xvpfz backup.tgz -C /

Or if you used bz2;

Code:
 tar xvpfj backup.tar.bz2 -C /

WARNING: this will overwrite every single file on your partition with the one in the archive!

Just hit enter/return/your brother/whatever and watch the fireworks. Again, this might take a while. When it is done, you have a fully restored Ubuntu system! Just make sure that, before you do anything else, you re-create the directories you excluded:

Code:
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
etc...

And when you reboot, everything should be the way it was when you made the backup!

2.1: GRUB restore
Now, if you want to move your system to a new harddisk or if you did something nasty to your GRUB (like, say, install Windows), You’ll also need to reinstall GRUB.
There are several very good howto’s on how to do that here on this forum, so i’m not going to reinvent the wheel. Instead, take a look here:

http://www.ubuntuforums.org/showthre…t=grub+restore

There are a couple of methods proposed. I personally recommend the second one, posted by remmelt, since that has always worked for me.

Well that’s it! I hope it was helpful!
As always, any feedback is appreciated!


Last edited by aysiu; November 29th, 2006 at 01:15 AM.. Reason: Moved slash to end of command by popular vote
  • Comments Off

OpenVZ Web Panel


OpenVZ Web Panel is a GUI web-based frontend for controlling of the hardware and virtual servers with the OpenVZ virtualization technology.

Announcements

  • 2011/04/17 - OpenVZ Web Panel 2.0 is available! It’s a major release. Most important features are Remote API, IP addresses management, virtual servers migration. Also a lot of bugfixes were made. Thanks to all the people who helped in release preparation. See ChangeLog for more details.

Demo

Demonstration of web panel’s user interface is below:

Installation

The most simple way to install OpenVZ Web Panel is to run the following command (under root):

wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

After installation Panel should be available by the following URL:

http://<your-host>:3000

Default administrator’s credentials are: admin/admin. Don’t forget to change default password.

  • Comments Off

I have a tiny embedded server (acrosser model) Intel Celeron with only 400MHz and 512MB Mem total. Before I upgraded debian to squeeze I used Xen, now its time to use OpenVZ.

Reasons:
- My tiny hardware:)
- Container virtualization – I can use more virtual machines
- Less memory usage – Container cannot boot

OpenVZ kernel and the vzctl and vzquota packages are available in the Debian repositories, so we can install them as follows:

1
aptitude update ; aptitude install linux-image-openvz-686 vzctl vzquota

Create a symlink from /var/lib/vz to /vz to provide backward compatibility and better usage:

1
ln -s /var/lib/vz /vz

Open vim /etc/sysctl.conf and make sure that you have the following settings in it:

1
2
3
4
5
6
7
8
9
10
11
[...]
net.ipv4.conf.all.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.ip_forward = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.eth0.proxy_arp = 1
[...]

View now your current config:

1
sysctl -p

Now its time to reboot and start your new kernel:

1
 reboot

After reboot you should see your fresh installed kernel:

1
2
nibbler ~ # uname -a
Linux nibbler 2.6.32-5-openvz-686 #1 SMP Tue Mar 8 23:30:33 UTC 2011 i686 GNU/Linux

Now we create our fist container, to do this we need a working template. A lot of templates can be founded here.
Of course you can create your own template. I describe it later:)

Choose one and download it to your template directory:

1
2
cd /vz/template/cache
wget http://download.openvz.org/template/precreated/contrib/debian-6.0-i386-minimal.tar.gz

After download don’t extract it!

1
2
3
4
5
6
7
8
vzctl create 01 –ostemplate debian-6.0-i386-minimal
vzctl set 01 –ipadd 192.168.1.77 –save
vzctl set 01 –nameserver 192.168.1.1 –save
vzctl set 01 –hostname gitcher –save
vzctl start 01
ping 192.168.1.77
vzctl exec 01 passwd
vzctl enter 01

Some basic commands:

1
2
3
4
5
6
7
8
9
10
vzlist
vzlist -a
vzctl stop 01
vzctl start 01
vzctl restart 01
vzctl status 01
vzctl umount 01
vzctl destroy 01
allocate disk space
vzctl set 01 –diskspace “10000000:11000000″ –save

UPDATE 30.06.2011 – Fix the default gateway
After VE creating the default gateway will be: 192.0.2.1 but whit is not my network.
You can set the default gateway in: /etc/vz/dists/scripts/functions

1
2
vim /etc/vz/dists/scripts/functions
FAKEGATEWAY=192.168.1.1
  • Comments Off

Installing !Openmeetings on debian etch

First variant (works with lenny as well):

Download the following debian package: http://www.expressaas.com/distrib/release/red5-openmeetings_1.0.2760.noarch.deb

And install it using sudo dpkg -i red5-openmeetings_1.0.2760.noarch.deb command. All additional utilities, such as Openoffice, Ghostscript, Imagemagick and Swftools should be installed as described below.

Second variant (outdated):

this sample is rather outdated

the installation procedure (if you forget of all 3th party requirements) is as simple as the following:

donwload openmeetings-package (you can download it into your home-directory)
unzip it
cd /openmeetings-package/webapps/openmeetings/conf and configure the hibernate.cfg.xml
cd up again to /openmeetings-package/ run the red5.sh

that is all!

no copy of any dirs, no /etc/init.d/, ^^ In doubt see what is written down in here:http://code.google.com/p/openmeetings/wiki/InstallationOpenMeetings There is no mention of any init.d-script or other copy actions.


In this how-to I’m going to descript way to install OpenMeetings on debian GNU/Linux Etch (4.0), Steps are following way:

  • What we need!
  • Install MySQL
  • Install xvfb and OpenOffice.org
  • Install ImageMagic & !Ghostscript
  • Install SwfTools
  • Install Java and red5
  • Download openlazslo
  • Install OpenMeetings
  • Installing must new version?
  • Configure OpenMeetings and place files
  • Start every thing
  • !Troobleshooting
  • Author

What We Need

In this article I will use aptitude to install packages, if you don’t have apptitude please install it before going forward :

$su
#apt-get update
#apt-get install aptitude

After aptitude we need Debian GNU/Linux, I use version 4.0 (code name Etch), befor installing any thing else I recommend you to create a directory and manage every thing from there:

#su
#mkdir /root/tmpOpenMeetings/
#cd  /root/tmpOpenMeetings/

Install !MySQL

OpenMeetings can work with wide range of databases, I will install OpenMeetings with MySQL, to install !MySQL server:

aptitude install mysql-server

Add/edit the following lines to /etc/mysql/my.conf to enable localization:

[mysqld]
default-character-set=utf8
character-set-server=utf8

Install xvfb and OpenOffice

If you would like exchange Presentation and Office documentation in OpenMeetings, you will nedd xvfb and OpenOffice.org

#aptitude install xvfb  openoffice.org

Then edit Setup.xcu:

#vim  /usr/lib/openoffice/share/registry/data/org/openoffice/Setup.xcu

You should insert following lines after: <node oor:name=”Office”>:

    <prop oor:name=“ooSetupConnectionURL” oor:type=“xs:string”>
        <value>socket,host=localhost,port=8100;urp</value>
    </prop>

Install ImageMagick and Ghostscript

ImageMagick is a software suite for image manipulation and display, supporting close to 100 image formats. It is mainly used to perform various transformation and conversion operations on images and Ghostscript is a suite of software based on an interpreter for Adobe Systems’ PostScript and Portable Document Format (PDF) page description languages.

To install this tools run:

 #aptitude install imagemagick  gs-gpl

Install SWFTools

SWFTools s a collection of SWF manipulation and creation utilities written by Rainer Böhme and Matthias Kramm. It is released under the GPL.

#aptitude install swftools

If you get this message: “Couldn’t find any package whose name or description matched “swftools” ” please download swftools directly from web with running:

#wget   http://ftp.it.debian.org/debian/pool/main/s/swftools/swftools_0.8.1-1_i386.deb

befor installing this ackage should install “libart-2.0-2 ” so run:

#aptitude install libart-2.0-2

and now install SWFTools:

#dpkg -i swftools_0.8.1-1_i386.deb

Install Java and Red5

red5 is a Open Source Flash Server that OpenMeetings based on, so you should install it, and befor installing red5 should install Java Runtime Environment and Java development Kit run:

#aptitude install sun-java5-bin
#aptitude install  sun-java5-demo
#

If aptitude gives you any error, please download all file with wget and then install

#wget http://ftp.tr.debian.org/debian/pool/non-free/s/sun-java5/sun-java5-demo_1.5.0-13-1_i386.deb
#wget http://ftp.de.debian.org/debian/pool/non-free/s/sun-java5/sun-java5-jdk_1.5.0-14-1etch1_i386.deb
# wget http://ftp.de.debian.org/debian/pool/non-free/s/sun-java5/sun-java5-bin_1.5.0-15-1_i386.deb
#dpkg -i sun-java5-demo_1.5.0-13-1_i386.deb sun-java5-jdk_1.5.0-14-1etch1_i386.deb sun-java5-bin_1.5.0-15-1_i386.deb 

Now download red5 for Debian GNU/Linux and install it:

#wget http://dl.fancycode.com/red5/0.6.3/debian/red5_0.6.3-1_all.deb
#dpkg -i red5_0.6.3-1_all.deb

openlazslo

OpenLaszlo is an open source platform for the development and delivery of rich Internet applications. to installing it, run:

#wget http://download.openlaszlo.org/4.0.6/openlaszlo-4.0.6-unix.tar.gz
#tar -xvf openlaszlo-4.0.6-unix.tar.gz
#mv lps-4.0.6/ /opt/

Note: there is no need to install OpenLaszlo if you only use the application but don’t want to modify it.

Note: you might would like to have a look at this shell script to start/stop/restart/status, if yes you can use this how-to.

Installing OpenMeetings

Huraaa, making infrastructure is finished, now we are going to download latest OpenMeeting release and instaling it:

#wget http://openmeetings.googlecode.com/files/openmeetings051.zip
#unzip openmeetings051.zip

To installing OpenMeetings you should tell OM where is your DataBase server and as I use MySQL as my Server, steps are like this:

#cp openmeetings/conf/mysql_hibernate.cfg.xml openmeetings/conf/hibernate.cfg.xml

Now edit file and config your database:

#vim openmeetings/conf/hibernate.cfg.xml

Now change :

            <property name=“connection.username”><DB_USER></property>
            <property name=“connection.password”><DB_PASSWORD></property>
            <property name=“connection.url”>jdbc:mysql://<DB_HOST>/<DB_NAME></property>

For example my config look likes:

 <!– User  / Password –>
                <property name=“connection.username”>root</property>
                <property name=“connection.password”>dj76shwrsh16xsvak1</property>

                <!– Database Settings –>
                <property name=“connection.driver_class”>com.mysql.jdbc.Driver</property>
                <property name=“dialect”>org.hibernate.dialect.MySQLInnoDBDialect</property>
                <property name=“connection.url”>jdbc:mysql://localhost/openmeetings?useUnicode=true&amp;createDatabaseIfNotExist=true&amp;characterEncoding=utf-8</property>

Installing Must new Version?

If you would like get must new version, I mean the version is under development, you should get a Snapshot from current source code, to do this follow this steps, if you don’t like to have any thing more than OpenMeetings latest version or don’t know what’s snapshot, skip this step.

#aptitude install subversion

Get (checkout) OpenMeetings latest snapshot:

#svn checkout http://openmeetings.googlecode.com/svn/branches/dev/

I will rename dev to !OpenMeetingsFromSVN and then replace what updated in snapshot (from subversion) with what should be out of date in orginal openmeetings file downloaded from OpenMeetings and OpnLazslo:

# mv dev/ OpenMeetingsFromSVN
#cp -r OpenMeetingsFromSVN/laszlo/client/xmlcrm/videoconference/ /opt/lps-4.0.6/Server/lps-4.0.6/ 

Configure OpenMeetings

Now, first I update my language files:

#cp OpenMeetingsFromSVN/xmlcrm/java/webapp/openmeetings/languages/*  openmeetings/languages/.

Ok, It’s time to place my OpenMeting in red5 document root to serving:

#cp -r openmeetings/ /usr/lib/red5/webapps/

Start every thing

Now time to start every thing we installed, I will start OpenOffice.org at first and then OpenLazslo and will start red5 server:

#xvfb-run –server-args=’-screen 0 800×600x16′ -a /usr/lib/openoffice/program/soffice -headless -nologo -norestore & 
#export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
#/opt/lps-4.0.6/Server/tomcat-5.0.24/bin/startup.sh
#/etc/init.d/red5 start

Instead of using a virtual frame buffer you may install and use a /etc/init.d/ooomeetings service.

The last part of instalation is web based, with your web browser (Firefox, Opera, IE, …) and servers IP address and port 5080 (default):

http://$YOUR_IP:5080/openmeetings/Install

For example: http://127.0.0.1:5080/openmeetings/Install

after putting information in forms, OpenMeetings will initialize a DataBase (based on information that we gived to him) and now you can access OpenMeetings first page at:

http://$YOUR_IP:8080/lps-4.0.6/videoconference/

For example: http://127.0.0.1:5080/openmeetings/

Congratulation, OpenMeetings is ready to use :)

Touble Shooting

If you get any message about locales or fonts, you can use :

#dpkg-reconfigure locales
#aptitude install xfonts-base

If you would like to change rtmp host, you can use:

vim  /opt/lps-4.0.6/Server/lps-4.0.6/videoconference/config.xml 
  • Comments Off

MRTG on Ubuntu Server

Lets start by installing the goods. Then we will get into the meat of things.

apt-get install snmpd mrtg apache2

When installing MRTG it will ask if you want to only make /etc/mrtg.cfg readable by the MRTG user. In my case, this will be an internal server only, and I do not need to worry about security, so I am going to select NO. If you choose YES, the steps in this tutorial may not work. I have not tested this. However, keep in mind if security is a concern, you may want to go this route and keep MRTG contained in a non-root user environment.

Assuming that you want to monitor your networking equipment with MRTG, you need to set up the snmp community on the piece of equipment. Usually its just a matter of enabling snmp, and the default community will be public. If you change the default community to another name, make sure you remember the name for later.

Now lets set up MRTG to read the data.
With Ubuntu server, MRTG will automatically set up /var/www/mrtg. In other distrobutions, it will set it up in a different area, so you will need to change the ‘WorkDir:’ variable in the following scenario to the directory where MRTG is installed.

I’m going to create an /etc/mrtg directory rather then move the mrtg.cfg file within /etc/ This will make it less confusing in the future.

mkdir /etc/mrtg

mv /etc/mrtg.cfg /etc/mrtg/

Now we run the cfgmaker command to get things up and running:

cfgmaker –global ‘WorkDir:/var/www/mrtg’ –global ‘Options[_]: bits,growright’ –output /etc/mrtg/mrtg.cfg public@<yourrouterip>

We need to make sure the following lines are correct in /etc/mrtg/mrtg.cfg If they are not there, add them.

EnableIPv6: no
RunAsDaemon: Yes
Interval: 5
Logdir: /var/log/mrtg

Now run:

indexmaker –output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

Which will build the index so you can view the output.

Then I run this command to set an environmental variable

env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

and open http://localhost/mrtg/index.html

You should now see an output graph.

crontab -e
0,5,10,15,20,25,30,35,40,45,50,55 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg –logging /var/log/mrtg.log

Let cron pick up stats for an hour or so. After a while, you will see that your graphs are picking up data about your bandwidth.

Here is mine with several cisco 2811 routers configured to show bandwidth.

SNMP and MRTG can monitor much more then bandwidth. For instance you can monitor disk usage, processing use, and more on your servers. There is plenty of documenation on the subject, which leans towards going in and adding snmpd to the servers you want to monitor, setting it up, and then going back and executing the cfgmaker and indexmaker command again so that the new hardware will show up on the page. Because the output of these files is an html page, you can also skin the page and make it look nicer, or embed it into your favorite CMS.

I encourage you to play around with MRTG, because it is the foundation program for a lot of software suites that monitor traffic. One of those, we will talk about next time. Until then, keep hackin.

  • Comments Off

A fax server with IAXmodem and Hylafax

The IAXmodem application emulates a faxmodem, which may be operated by a fax application of the administrator’s choosing. We’ll use the popular Hylafax. For simplicity and consistency, the installation platform will be the same Debian Linux and Asterisk 1.4 we have used for the other examples (see the section called “Installing Asterisk 1.4.x on Debian Linux 4.0 (Etch)”).
Installing IAXmodem

IAXmodem simulates a faxmodem and makes it available to Asterisk via IAX2. All the steps in this chapter must be performed as the root user.

To install IAXmodem, we need some additional Debian packages, which may be installed with the command apt-get -y install g++ libtiff-tools libtiff4 libtiff4-dev.

debian:~# apt-get -y install g++ libtiff-tools libtiff4 libtiff4-dev
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Die folgenden zusätzlichen Pakete werden installiert:
g++ libjpeg62 libjpeg62-dev libtiffxx0 zlib1g-dev

[...]

Richte zlib1g-dev ein (1.2.2-4.sarge.2) …
Richte libtiff4-dev ein (3.7.2-7) …

debian:~#

We switch into the appropriate directory with cd /usr/src to install the IAXmodem source code:

debian:~# cd /usr/src
debian:/usr/src#

The sources for IAXmodem can be downloaded with any typical web browser from http://iaxmodem.sourceforge.net (the version used in this example is 0.3.0). After downloading the archive, copy it to /usr/src and unpack it with tar -xvzf iaxmodem-0.3.0.tar.gz.

debian:/usr/src# tar -xvzf iaxmodem-0.3.0.tar.gz
iaxmodem-0.3.0/
iaxmodem-0.3.0/iaxmodem.c
iaxmodem-0.3.0/iaxmodem.init.debian
iaxmodem-0.3.0/Makefile.in
iaxmodem-0.3.0/CHANGES
iaxmodem-0.3.0/lib/
iaxmodem-0.3.0/lib/spandsp/
iaxmodem-0.3.0/lib/spandsp/Makefile.am

[...]

iaxmodem-0.3.0/TODO
iaxmodem-0.3.0/FAQ
iaxmodem-0.3.0/build
iaxmodem-0.3.0/iaxmodem.init.fedora
debian:/usr/src#

Change into the unpacked directory with cd iaxmodem-0.3.0:

debian:/usr/src# cd iaxmodem-0.3.0
debian:/usr/src/iaxmodem-0.3.0#

Now compile the sources with ./configure && make:

debian:/usr/src/iaxmodem-0.3.0# ./configure && make
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for gawk… no
checking for mawk… mawk
checking whether make sets $(MAKE)… yes
checking for gcc… gcc

[...]

cc -DMODEMVER=\”0.3.0\” -DDSPVER=\”spandsp-0.0.3-snapshot-20070223+\” -D
IAXVER=\”libiax2-0.2.3-CVS-20060222+\” -Wall -g -DSTATICLIBS -DUSE_UNIX9
8_PTY -std=c99 -Ilib/libiax2/src -Ilib/spandsp/src -c iaxmodem.c
cc -DMODEMVER=\”0.3.0\” -DDSPVER=\”spandsp-0.0.3-snapshot-20070223+\” -D
IAXVER=\”libiax2-0.2.3-CVS-20060222+\” -Wall -g -DSTATICLIBS -DUSE_UNIX9
8_PTY -std=c99 -Ilib/libiax2/src -Ilib/spandsp/src iaxmodem.o lib/spand
sp/src/.libs/libspandsp.a lib/libiax2/src/.libs/libiax.a -o iaxmodem -lm
-lutil -ltiff

[...]

debian:/usr/src/iaxmodem-0.3.0#

Copy the resulting binary into /usr/bin with cp iaxmodem /usr/bin/:

debian:/usr/src/iaxmodem-0.3.0# cp iaxmodem /usr/bin/
debian:/usr/src/iaxmodem-0.3.0#

Now we can configure the modem. IAXmodem expects to find configuration files in /etc/iaxmodem. Create it with mkdir /etc/iaxmodem:

debian:/usr/src/iaxmodem-0.3.0# mkdir /etc/iaxmodem
debian:/usr/src/iaxmodem-0.3.0#

Create the configuration file with touch /etc/iaxmodem/ttyIAX0:

debian:/usr/src/iaxmodem-0.3.0# touch /etc/iaxmodem/ttyIAX0
debian:/usr/src/iaxmodem-0.3.0#

This file must contain the following parameters:

device
The device node to be created in /dev. This is the device Hylafax uses to connect to IAXmodem. You can choose any name you like, but we prefer to adhere to the convention and so choose a device name appropriate for a serial interface, ttyIAX0.
owner
This is the owner of the device (in the form user:group). It is best to use the same user and group under which Hylafax runs.
port
The port that IAXmodem listens on. Asterisk uses 4569 to listen for IAX2 connections, so you must choose something else, e.g. 4570.
refresh
This sets how long IAXmodem waits between registrations with Asterisk. If this number is 0, the modem does not register at all.
server
IP address of the server running Asterisk. If this is on the same machine as IAXmodem, use the localhost address 127.0.0.1.
peername
The name under which IAXmodem registers with Asterisk.
secret
The password used for Asterisk registration.
codec
The codec used by IAXmodem. Allowed codecs are alaw, ulaw and slinear. Compressed codecs are not appropriate for faxing; fax transmissions are themselves compressed and don’t tolerate further compression; moreover, most compressed codecs are lossy and a fax transmission will not tolerate losses. This is one of the major reasons why faxing over VoIP remains problematic.

Using an appropriate editor (e.g. vi) we write the following configuration in the file /etc/iaxmodem/ttyIAX0:

device /dev/ttyIAX0
owner uucp:uucp
mode 660
port 4570
refresh 50
server 127.0.0.1
peername iaxmodem
secret password
codec alaw

IAXmodem is now configured and can be started. The best way to do this is with init. Add a line to start IAXmodem to /etc/inittab with echo “IA00:23:respawn:/usr/bin/iaxmodem ttyIAX0″ >> /etc/inittab:

debian:/usr/src/iaxmodem-0.3.0# echo “IA00:23:respawn:/usr/bin/iaxmodem
ttyIAX0″ >> /etc/inittab
debian:/usr/src/iaxmodem-0.3.0#

The device name ttyIAX0 is the same device name as specified in /etc/iaxmodem.

To receive faxes, we need a getty that listens for connections on the IAXmodem. This is accomplished through an additional entry in /etc/inittab. Add it with echo “mo00:23:respawn:/usr/sbin/faxgetty ttyIAX0″ >> /etc/inittab.

mo00:23:respawn:/usr/local/sbin/faxgetty ttyIAX0

Create a log directory for IAXmodem with mkdir /var/log/iaxmodem/ and the log files with touch /var/log/iaxmodem/ttyIAX0 and touch /var/log/iaxmodem/iaxmodem.

debian:/usr/src/iaxmodem-0.3.0# mkdir /var/log/iaxmodem/
debian:/usr/src/iaxmodem-0.3.0# touch /var/log/iaxmodem/ttyIAX0
debian:/usr/src/iaxmodem-0.3.0# touch /var/log/iaxmodem/iaxmodem
debian:/usr/src/iaxmodem-0.3.0#

To make sure everything will start as expected at boot time, reboot the system with shutdown -r now.

debian:/usr/src/iaxmodem-0.3.0# shutdown -r now

Broadcast message from root@debian (pts/1) (Sat May 5 00:15:49 2007):

The system is going down for reboot NOW!
debian:/usr/src/iaxmodem-0.3.0#

Installing Hylafax

We’ll install Hylafax from the Debian Repository to simplify installation. Do this with apt-get -y install hylafax-server . Dependencies are automatically resolved:

debian:~# apt-get install -y hylafax-server
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Die folgenden zusätzlichen Pakete werden installiert:
enscript gs-common gs-esp hylafax-client libcupsimage2 libcupsys2 mail
x metamail psmisc
Vorgeschlagene Pakete:
gv postscript-viewer lpr gs-pdfencrypt gs-cjk-resource mgetty-viewfax
hylafax-doc mgetty cupsys-common
Empfohlene Pakete:
psfontmgr netpbm transfig
Die folgenden NEUEN Pakete werden installiert:
enscript gs-common gs-esp hylafax-client hylafax-server libcupsimage2
libcupsys2 mailx metamail psmisc

[...]

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 old protocol: no
[4] 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.

Restarting HylaFAX server processes.

Should I restart the HylaFAX server processes [yes]?
You do not appear to have any modems configured for use. Modems are
configured for use with HylaFAX with the faxaddmodem(8) command.
Do you want to run faxaddmodem to configure a modem [yes]?
Done verifying system setup.
Updating /etc/hylafax/setup.cache from /var/spool/hylafax/etc/setup.cach
e.
Updating /etc/hylafax/setup.modem from /var/spool/hylafax/etc/setup.mode
m.apt-get -y install hylafax-server
/var/spool/hylafax
Starting HylaFAX: faxq hfaxd faxgetty.

debian:~#

The next step is the configuration of the fax server. Do this with faxsetup:

debian:/usr/src/hylafax-4.3.4# faxsetup

[...]

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 old protocol: no
[4] Start paging protocol: no

Are these ok [yes]?

Simply press Enter after the following 2-3 questions.

You have a HylaFAX scheduler process running. faxq will be
restarted shortly, as soon as some other work has been completed.
Can I terminate this faxq process (4048) [yes]?
Should I restart the HylaFAX server processes [yes]?

/etc/init.d/hylafax start
Not starting HylaFAX daemons since they are already running.

[...]

Modems are configured for use with HylaFAX with the faxaddmodem(8) comma
nd.
Do you want to run faxaddmodem to configure a modem [yes]?

We confirm restart of the server processes with yes and are asked if we want to install a modem. Our IAXmodem is already set up so we can proceed and confirm again with yes.

Specify the modem and confirm with Enter.

Serial port that modem is connected to [ttyS0]? ttyIAX0

Ok, time to setup a configuration file for the modem. The manual
page config(5) may be useful during this process. Also be aware
that at any time you can safely interrupt this procedure.

Reading scheduler config file /var/spool/hylafax/etc/config.

Many questions follow, but only a few of them are really important.[44]This is where you set international dialing codes, the fax number, country and area code, and the CSID (Call Subscriber ID) which is printed on the top line of the fax page on the receiver’s end. Confirm with yes.

No existing configuration, let’s do this from scratch.

Country code [1]? 1
Area code []? 403
Phone number of fax modem [+1.999.555.1212]? +1 888 555 4091
Local identification string (for TSI/CIG) ["NothingSetup"]?
Long distance dialing prefix [1]? 1
International dialing prefix [011]? 011
Dial string rules file (relative to /var/spool/hylafax) [etc/dialrules]?

Tracing during normal server operation [1]?
Tracing during send and receive sessions [11]?
Protection mode for received facsimile [0600]?
Protection mode for session logs [0600]?
Protection mode for ttyIAX0 [0600]?
Rings to wait before answering [1]?
Modem speaker volume [off]?
Command line arguments to getty program ["-h %l dx_%s"]?
Pathname of TSI access control list file (relative to /var/spool/hylafax
) [""]?
Pathname of Caller-ID access control list file (relative to /var/spool/h
ylafax) [""]?
Tag line font file (relative to /var/spool/hylafax) [etc/lutRS18.pcf]?
Tag line format string ["From %%l|%c|Page %%P of %%T"]?
Time before purging a stale UUCP lock file (secs) [30]?
Hold UUCP lockfile during inbound data calls [Yes]?
Hold UUCP lockfile during inbound voice calls [Yes]?
Percent good lines to accept during copy quality checking [95]?
Max consecutive bad lines to accept during copy quality checking [5]?
Max number of pages to accept in a received facsimile [25]?
Syslog facility name for ServerTracing messages [daemon]?
Set UID to 0 to manipulate CLOCAL [""]?
Use available priority job scheduling mechanism [""]?

A confirmation page follows where you can double-check your entries:

The non-default server configuration parameters are:

CountryCode: 1
AreaCode: 403
FAXNumber: +1 888 555 4091
LongDistancePrefix: 0
InternationalPrefix: 00
DialStringRules: etc/dialrules
SessionTracing: 11
RingsBeforeAnswer: 1
SpeakerVolume: off
GettyArgs: “-h %l dx_%s”
LocalIdentifier: “NothingSetup”
TagLineFont: etc/lutRS18.pcf
TagLineFormat: “From %%l|%c|Page %%P of %%T”
MaxRecvPages: 25

Are these ok [yes]?

Answering yes brings us to modem detection:

Now we are going to probe the tty port to figure out the type
of modem that is attached. This takes a few seconds, so be patient.
Note that if you do not have the modem cabled to the port, or the
modem is turned off, this may hang (just go and cable up the modem
or turn it on, or whatever).

Probing for best speed to talk to modem: 38400 OK.

About fax classes:

The difference between fax classes has to do with how HylaFAX interacts
with the modem and the fax protocol features that are used when sending
or receiving faxes. One class isn’t inherently better than another;
however, one probably will suit a user’s needs better than others.

Class 1 relies on HylaFAX to perform the bulk of the fax protocol.
Class 2 relies on the modem to perform the bulk of the fax protocol.
Class 2.0 is similar to Class 2 but may include more features.
Class 1.0 is similar to Class 1 but may add V.34-fax capability.
Class 2.1 is similar to Class 2.0 but adds V.34-fax capability.

HylaFAX generally will have more features when using Class 1/1.0 than
when using most modems’ Class 2 or Class 2.0 implementations. Generally
any problems encountered in Class 1/1.0 can be resolved by modifications
to HylaFAX, but usually any problems encountered in Class 2/2.0/2.1 will
require the modem manufacturer to resolve it.

If you’re unsure and your modem supports it, use Class 1.

This modem looks to have support for Class 1 and 1.0.
How should it be configured [1]?

Hmm, this looks like a Class 1 modem.
Product code (ATI0) is “spandsp”.
Other information (ATI3) is “www.soft-switch.org”.
DTE-DCE flow control scheme [default]?
Modem manufacturer is “spandsp”.
Modem model is “IAXmodem”.

Using prototype configuration file iaxmodem…

The modem configuration parameters are:

ModemResetCmds: “ATH1\nAT+VCID=1″

Are these ok [yes]?

The modem was detected and we are asked if it is a Class 1 modem, and we confirm this because it is exactly what we want. The default reset commands are also acceptable. Confirm with yes.

Answer the first question In the next dialog with no, since we don’t need to configure any further modems. The second question is confirmed with by pressing Enter, which starts the fax server.

Creating new configuration file /var/spool/hylafax/etc/config.ttyIAX0…
Creating fifo /var/spool/hylafax/FIFO.ttyIAX0 for faxgetty… done.
Done setting up the modem configuration.

[...]

Do you want to run faxaddmodem to configure another modem [yes]? no

[...]

Should I run faxmodem for each configured modem [yes]?
/usr/sbin/faxmodem ttyIAX0

Done verifying system setup.
/var/spool/hylafax

debian:~#

Hylfax is now configured for sending faxes.
Receiving faxes

Our fax solution still has to be integrated into Asterisk. To do this, we configure the IAXmodem as an IAX2 peer by adding a section to /etc/asterisk/iax.conf (see also ???):

[general]
bindport = 4569
bindaddr = 0.0.0.0
disallow=all
allow=ulaw
allow=alaw

[iaxmodem]
type=friend
secret=password
port=4570
host=dynamic
context=fax-out
disallow=all
allow=alaw

Global settings are defined in the general section. In this example we are binding the standard IAX2 port of 4569. The bindaddr defines the IP address (and thereby the interface) on which the IAX2 channel driver listens for connections; in this case, it is set to listen on all interfaces.

The IAXmodem is set to type friend, which allows both incoming and outgoing connections. The secret and port parameters match those in the IAXmodem configuration we did above, and context defines the entry context for outgoing connections.

Enter iax2 show peers in the Asterisk console to see our new IAXmodem:

*CLI> iax2 show peers
Name/Username Host Mask Port Sta
tus
iaxmodem 127.0.0.1 (D) 255.255.255.255 4570 Unm
onitored
1 iax2 peers [0 online, 0 offline, 1 unmonitored]
*CLI>

We are, of course, not done yet. Asterisk still needs an extension so that it knows what to do with an incoming fax. Our objective is to ensure that any incoming faxes are passed on to Hylafax. In this example, we assume that all faxes come in through a SIP provider. A real configuration will have to reflect the installation and account settings of the SIP provider you use; for the sake of example, a configuration in sip.conf might look like this:

[...]

[123456]
type=friend
insecure=very;
nat=yes
username=123456
fromuser=12345
fromdomain=my-voip-provider.com
secret=secret
host=my-voip-provider.com
qualify=yes
context=fax-in

[...]

The corresponding context in extensions.conf would look like this:

[fax-in]
exten => _X.,1,Dial(IAX2/iaxmodem)

Any faxes coming in will now be routed to Hylafax via IAXmodem and ultimately e-mailed to the user address defined in the faxmaster alias.
Sending faxes

The next obvious step is configuring our system to send faxes. Here, too, we need a context (this time it is [fax-out]) in extensions.conf. If IAXmodem wants to send a fax, it will automatically land in this context. If the faxes are to go out our hypothetical SIP connection 123456, the entry in extensions.conf will look like this:

[fax-out]
exten => _X.,1,Dial(SIP/123456/${EXTEN})

We can test sending of faxes with sendfax -n -d :

debian:~# sendfax -n -d 6045557977 /etc/issue.net

We should see this in the CLI:

— Accepting AUTHENTICATED call from 127.0.0.1:
> requested format = alaw,
> requested prefs = (),
> actual format = alaw,
> host prefs = (alaw),
> priority = mine
— Executing Answer(”IAX2/iaxmodem-3″, “”) in new stack
— Executing Dial(”IAX2/iaxmodem-3″, “SIP/123456/6045557977″) in new
stack
— Called 123456/6045557977
— SIP/123456-0818f630 is making progress passing it to IAX2/iaxmode
m-3
— SIP/123456-0818f630 answered IAX2/iaxmodem-3
— parse_srv: SRV mapped to host my-voip-provider.com, port 5060
== Spawn extension (fax-out, 6045557977, 2) exited non-zero on ‘IAX2/i
axmodem-3′
— Executing Hangup(”IAX2/iaxmodem-3″, “”) in new stack
== Spawn extension (fax-out, h, 1) exited non-zero on ‘IAX2/iaxmodem-3

— Hungup ‘IAX2/iaxmodem-3′

If we issue the command faxstat -s during the transmission, we will see:

debian:~# faxstat -s
HylaFAX scheduler on w077.example.com: Running
Modem ttyIAX0 (123456): Sending job 7

JID Pri S Owner Number Pages Dials TTS Status
7 127 R root 06912345678 0:1 0:12
debian:~#

Done! Now you can send and receive faxes via Asterisk using Hylafax.

The Hylafax website http://www.hylafax.org has numerous examples and how-tos that will help you integrate your Hylafax installation with your existing office intrastructure effectively.
Sending received faxes as e-mail

The following steps illustrate how we can configure Hylafax to transmit incoming faxes to a pre-defined e-mail address.[45]The recipient will receive the fax as an e-mail attachment.

To do this, the configuration file /var/spool/hylafax/etc/FaxDispatch must contain the following parameters:

SENDTO
The destination e-mail address for incoming faxes.
FILETYPE
The format of the attachment. In addition to pdf, tiff (Tagged Image File Format) and ps (Postscript™) are also acceptable options.

SENDTO=fax-incoming@company.com
FILETYPE=pdf

After the file has been saved, you must restart the fax server with /etc/init.d/hylafax restart.

debian:~# /etc/ini.d/hylafax restart
Starting HylaFAX: faxq hfaxd.
debian:~#

We can test e-mail transmission by sending ourselves a fax with sendfax -n -d

debian:~# sendfax -n -d 6045557977 /etc/issue.net

After a short time your target e-mail address should receive an e-mail in the following format:

recvq/fax000000016.tif (ftp://debian:4559/recvq/fax000000016.tif):

Sender: IAXmodem
Pages: 4
Quality: Normal
Size: North American Letter
Received: 2007:06:02 02:49:45
Time To Receive: 1:58
Signal Rate: 9600 bit/s
Data Format: 2-D MMR
Error Correct: Yes
CallID1: 2007
CallID2: IAXmodem 1
Received On: ttyIAX0
CommID: 000000033 (ftp://debian:4559/log/c000000033)

[...]

Jun 02 02:51:46.99: [ 3320]: RECV FAX: bin/faxrcvd “recvq/fax000000016.t
if” “ttyIAX0″ “000000033″ “COMREC received DCN” “2007″ “IAXmodem 1″ “ NE>” “s”
Jun 02 02:51:47.00: [ 3320]: RECV FAX: end
Jun 02 02:51:47.00: [ 3320]: SESSION END
Jun 02 02:51:47.01: [ 3320]: RECV FAX (000000033): recvq/fax000000016.ti
f from IAXmodem, route to , 4 pages in 2:08

The attachment will be a PDF file. In this example, the PDF is named fax000000016.pdf.

Now you can not only send and receive faxes, but received faxes are also received as e-mail attachments.

  • Comments Off

Time

Mp3

Msn status

  • manon2029@hotmail.com is

Chat with Meeh

Donate

    If you find an article useful, then please make a donation.

หมวดหมู่

UserOnline

Counter

  • Visitors today: 186
  • Visitors yesterday: 535
  • Visitors per day: 3,132
  • Max. visitors per day: 665
  • Total page views: 749,949
  • Page views of this page: 3,132
  • Currently online: 9
  • Max. online: 192
  • Total visitors: 157,603
  • counterStatistics