I was tasked with setting up a Hylafax server using Ubuntu 10.04 LTS and running Avantfax. I’ll not get into the specific reasoning behind all of that, it’s just how things had to be done. Seeing as how I have never set up Avantfax before… nor Hylafax… I ran into a few issues and thought I’d log a few things here for later reference and just to have the information out there on the interwebs in case anyone else could find the information useful. So here goes….

How to install Hylafax and Avantfax on Ubuntu 10.04. Yes, you can install Hylafax and Avantfax on Ubuntu 10.04, here's how to do it!

Ubuntu

I started off with a base install of Ubuntu Desktop 10.04.02 LTS because that is what I had on a CD here and was just too lazy to download and burn the Server edition. And let’s face it, aside from all the extra GUI stuff, they are basically the same thing… Linux is Linux, as you know… for the most part.

While I prefer using Debian, I must hand it to Ubuntu for the ease of getting that old PCI winmodem setup and running. But I digress.

Ubuntu 10.04.02 LTS, after installation and updating, provided me with Hylafax 6.0.3 after issuing “apt-get install hylafax-server”. That wasn’t too far off the mark for the latest version on the Hylafax website, so I stuck with it. After apt downloaded the dependencies it gave me a nice basic configuration for Hylafax. Since this is just a single modem fax server, all that was left was to run “faxsetup” from the command line. I’ll not get into the specifics of what I did to get the modem working; you have access to Google, use it. After going through the seemingly never-ending prompts from faxsetup, I had a nice /etc/hylafax/config.modem that I was happy with. Now was the time to test it out, just to see if I could send a fax. From the command line I typed:

sendfax -n -d xxxxxxxxxx /usr/share/doc/hylafax-server/copyright

What this does, is sends a test fax to the number supplied (xxxxxxxxxx in my case) and sends the contents of the copyright file in the hylafax-server doc folder supplied by the Debian package. All was good, now came the fun-difficult-confusing part… Avantfax.

I grabbed the latest Avantfax (Version 3.3.3) from http://sourceforge.net/projects/avantfax/ using wget (man has wget come a long way since the last time I used it) and then untarred it in my working directory. Without going into too much detail about how much hair I pulled out or how many times I failed, I’ll just write this from the prospective that I knew what I was doing from the get-go.

So I entered avantfax-3.3.3/ and edited debian-prefs.txt, which has a few configuration options for the debian-install.sh script that is supplied with Avantfax. As far as a Debian or Ubuntu install goes, it’s pretty much good the way it is. Just change FAXDOMAIN and you can call it a day. But if you already have MySQL installed then you’ll need to supply the MySQL root password where it asks. Also, it has a password already in place for the Avantfax MySQL user that will be created. If you want to leave it as is, fine, so long as your server is not accessible from the outside world and you trust your users I suppose. But I changed it, which caused a minor issue later on, which I will talk about. So go ahead and change it if you want, the minor issue I mentioned really was “minor”.

OK, so those settings have been changed and I’m ready to install Avantfax. Run the debian-install.sh script. It will download all the stuff you need via apt such as Mysql (if you don’t have it already), Apache, etc., does its thing with pear for PHP, and even gives you a bit of false information at the end (more on that in a moment).

OK, so you ran the debian-install.sh script… you’re almost done. If something went completely haywire, don’t run it again, and don’t follow these instructions any further. But if the script completes and the only error you get is about Apache not restarting, then you know you are on the right track.

That’s right, I said Apache would fail to restart. And a moment ago I said it will give you some false information. Apache fails to restart because the entry it added to your /etc/apache2/sites-enabled/000-default has a bit of broken-ness to it. Is broken-ness a word? Yes, you could have edited the script to fix it, but I like doing things the hard way. Anyhow, open the /etc/apache2/sites-enabled/000-default file and scroll to the bottom. You’ll be looking for these two entries:

"ErrorLog logs/avantfax-error_log"
"CustomLog logs/avantfax-access_log common"

Change them to:

"ErrorLog /var/log/apache2/avantfax-error_log"
"CustomLog /var/log/apache2/avantfax-access_log common"

Or change them to reflect where you want to keep your logs files for Avantfax in the case that you don’t like the way I did it. But the important thing is to make sure that the directory exists and www-data can write to it. That’s what caused this mess.

The second little hiccup in the install script is that it tells you to:

“Log into the Administrative interface at: http://ip.address.of.server/admin/”

Well, that’s wrong, it doesn’t even create an /admin/ in the ServerRoot. The guy who wrote this was just playing a nasty joke on me. In reality, you should go to:

"http://ip.address.of.server/avantfax/"

But before you do that, let’s make one more change… if you want to. The machine I set this up on is a dedicated Avantfax/Hylafax server, there’s nothing else on it. So I’ll set the ServerRoot to redirect to the /avantfax/ directory.

echo "avantfax/">" > /var/www/index.html

Almost done now!

Remember back when you were editing debian-prefs.txt and there was a section to change the default Avantfax MySQL password? If you changed it, you’ll have to do one more things before being able to log in. You’ll have to edit /var/www/avantfax/includes/local_config.php and set “AFDB_PASS” to reflect that change. Otherwise, go ahead and log into your new Avantfax/Hylafax server with the default username of admin and the password of password … then change the password.

Now we are on to the final configurations in order to make this thing work correctly and iron out a few bugs.

Edit /var/www/avantfax/includes/local_config.php again, this time making the following changes:

set $WWWUSER to “www-data”
set $COVERPAGE_FILE to “/var/www/avantfax/images/coverpage.html”
set $HTML2PS to “/usr/bin/html2ps”
set $PAPERSIZE to “letter”

These are just the necessary changes that need to be made in order to get Avantfax to behave. You can, of course, change anything you want in there. Also, note that I am setting this up to use the nifty HTML cover pages. I hate dealing with postscript and love this feature! Oh yeah, while we are at it, in order to use that feature you’ll have to:

apt-get install html2ps

OK, still with me? We’re on the home stretch now.

Edit /etc/hylafax/config and add the following:

Use2d: no

For more information on that, use your google-fu. I’m still not 100% certain of why that was necessary. All I know is that I could have shaved off 5 hours of config time by having that little piece of information available to me up front.

Let’s go ahead and fix the font issue that you are going to get before it happens. Edit /etc/hylafax/hyla.conf and look for the FontMap: setting. You’ll want to add:

“/var/lib/defoma/gs.d/dirs/fonts:” to it. In fact, it’d be best to have that be the first path. My setting looks like this:

FontMap: /var/lib/defoma/gs.d/dirs/fonts:/usr/share/ghostscript/8.70/lib:/usr/share/ghostscript/8.62/lib:/usr/share/gs-esp/8.15/lib:/usr/share/gs-esp/7.07/lib:/usr/share/gs/6.53
FontPath: /usr/share/fonts/type1/gsfonts

Last, but not least, let’s fix the issue where the cover page only faxes when there is no fax to send. Likewise, when you send a fax, the coverpage doesn’t go out. Odd enough… here’s how to fix it.

Edit /var/www/avantfax/includes/functions.php.  You’re looking for qa specific if-then statement that’ll need to be fixed.

Line 531 should start with: if (count($files)) {

In fact, the entire section that needs to be modified is:

if (count($files)) {
$faxfiles = implode(” “, $files);
return exec_sendfax(“$SENDFAX $nrequeue $use_coverpage $sf_args $modem $destinations $faxfiles”);

Here is what you should change it to:

if (count($files)) {
//$faxfiles = implode(" ", $files);
$psfile = $TMPDIR.genpasswd().".ps";
$fcommand = "$FAXCOVER $cp_args -C '" . $INSTALLDIR . "/images/$whichcover' -p $NUM_PAGES_FOLLOW -n $first_dest > $psfile";
$o = exec($fcommand, $output, $retval);
array_unshift($files,$psfile);
$faxfiles = implode(" ", $files);
return exec_sendfax("$SENDFAX $nrequeue $use_coverpage $sf_args $modem $destinations $faxfiles");

//return exec_sendfax(“$SENDFAX $nrequeue $use_coverpage $sf_args $modem $destinations $faxfiles”);

I just commented out the old stuff (//) so you can see exactly what I did there. I’d like to thank Matteo Fabbroni for his insight on this little piece of forehead-to-the-wall-pounding-fix insight.

And well, there you have it.

I have noticed one thing that I have yet to fix. Every time you add a user with Avantfax, the /etc/hosts.hfaxd gets blanked out, meaning the contents of the file gets removed. This isn’t good, because without the control in there PAM pukes out when you try to send a fax. So I just saved my known good hosts.hfaxd and copy it back over every time I add a user. This server is pretty much wide open to the internal network and firewalled from the outside anyhow, so the local subnet is all I need to allow access to.

There you have it, you now have Installed Hylafax and Avantfax on Ubuntu 10.04! I hope this comes in handy for someone else.

Brandon