Linux tips & techniques for developers and system administrators.


3,783 views

Installing PostgreSql 8.3 on Ubuntu 10.04 or later (Karmic)

By jbayer - Last updated: Tuesday, May 31, 2011

Ubuntu started shipping  Postgresql 8.4 with Karmic (10.04).  Postgresql 8.3 is not available in the Karmic or later repositories.

If you need 8.3 for an application, you can easily install it by using the following steps:

At the command line:

echo "deb http://us.archive.ubuntu.com/ubuntu/ karmic main universe multiverse" >>/etc/apt/sources.list
apt-get update
apt-get install postgresql-8.3
sed -i '/karmic/s/^/#/g' /etc/apt/sources.list

What this does is as follows:

  1. Add a line to the /etc/apt/sources.list pointing to the karmic (9.10) repository.  Important that it is the last line
  2. Update apt
  3. Install postgresql 8.3
  4. Finally, comment out that line which was added.

When this is done, Postgresql 8.3 is installed and running.  It is possible to have both 8.3 and 8.4 running at the same time, the paths for each configuration files and database files are unique to each.

Filed in Administration, Database, Linux Installations
5,635 views

Installing Ganeti on a Redhat 6 or Scientific Linux 6 system

By jbayer - Last updated: Thursday, May 12, 2011

Ganeti is a cluster virtual server management software tool built on top of existing virtualization technologies such as Xen or KVM and other Open Source software.  It is written by Google, and is available from the Google code site.

The instructions on the code site refer to installing on a Debian-based system.  We are a Redhat shop, using either CentOS or Scientific Linux as the base os; both are rebrandings of the Redhat RPMs.

After googling for a while, I found a japanese site, http://jfut.integ.jp/linux/ganeti,  which had source RPMs for Redhat 5 & 6, as well as written instructions in english.  These instructions, while mostly complete, still assumes that the user do some tasks without being told.

During my work, I had to install Ganeti many times, and ended up writing a script to do the entire install, starting with a minimal or base desktop install on Scientific Linux 6.  While not tested, the script should work on Redhat 6 as well.  My script incorporates the instructions from jfut.integ.jp, as well as other steps and some code of my own to setup the bridges.  The only other requirement is access to the ‘net.

All files are available here, as well as the original Japan locations:

bridge.sh

  bridge.sh (1.5 KiB, 880 hits)

calculate-address

  calculate-address (1,013 bytes, 1,010 hits)

ganeti rpm

  ganeti-2.4.2-1.el6.noarch.rpm (1.1 MiB, 490 hits)

ganeti debootstrap

  ganeti-instance-debootstrap-0.7-2.el5.noarch.rpm (19.0 KiB, 517 hits)

ganeti install script (updated 6/20/11)

  ganeti.sh (32.1 KiB, 843 hits)

Using the script

I like using both the screen program and Free-NX.  If they aren’t installed my script asks if you want them installed.

In all questions, if there are answers in parentheses, pressing <return> will enter the default answer, which will be inside the parentheses.  If there are two choices in side the parentheses, the default will be in caps.

The first two questions will be about the screen program and Free-NX, answer as you like, they are not needed for the install.

If you are using Scientific Linux, you will be asked about the Fastbug repo.  I usually answer yes; again, this is not required.

After a number of RPMs are installed the following questions are asked:

Enter primary network interface (eth0):

The following question does not have a default answer.  You must answer either M or S (case is not important):

Is this the Master server or a Slave node (M/S):

The hostname is obtained from the system, and presented here for confirmation:

Enter hostname (localhost.localdomain):
Enter cluster name:
Enter cluster address (must be unused):
Enter cluster netmask (255.255.255.0):

The cluster network is derived from the address and netmask, and presented here for confirmation:

Enter cluster network (10.50.10):
Enter domain:

The default prefix for the node name is: “node”:

Enter node name prefix (node):
Enter node starting address:
Enter number of nodes you want:

The default prefix for the instances is: “instance”:

Enter instance name prefix (instance):
Enter instance starting address:
Enter number of instances you want:

Some more modules are installed, then:

Enter device partition for the LVM partition
(ie: /dev/sda4, press <CR> to automatically find the LVM partition):

If the volume group is already created, you will get the following error:

Can't initialize physical volume "/dev/sda4" of volume group "vmvg" without -ff
Error running:  pvcreate /dev/sda4
Please fix the problem and try again
Press <CR> to retry, or C to continue with the next step:

Enter volume group name, must be identical on all nodes (vmvg):

Ganeti will be downloaded and installed now.

There is a bug/incompatibility with the certificates which Ganeti generates which causes an error at this point.  The error message will be:

Failure: command execution error:
Node daemon on dev-ha1.regcolo.com didn't answer queries within 10.0 seconds

Rc: 1
Do you need to fix the error now (Y/n):

Press <return> to have the script regenerate the certificates automatically.  Assuming you do, you will be presented with the following query, two times.  Just press <return> when asked:

Enter PEM pass phrase:

Finally, the last question will be about doing a full system update:

Would you like to do a full system update (Y/n):

At the end, the system is rebooted.

Manual Steps, if you like doing it yourself

Start off by doing a clean install of Scientific Linux 6.  Make the OS partition between 20 and 40 gig in size, swap as needed, and create an LVM partition where the virtual systems will reside.  Do not initialize the LVM partition, just create it and mark it as LVM.

Install the repos for epel, atrpms, elrepo and rpmforge.  You can use this command:

yum install epel-release atrpms-repo elrepo-release rpmforge-release

If you want to use my scripts to create the bridges, you will also need to install ksh, since one of the scripts is currently written in ksh instead of bash:

yum install ksh

Download and install the following two scripts in /usr/local/sbin:

calculate-address:

bridge.sh:

Turn off iptables:

chkconfig iptables off

and add the following to /etc/rc.local:

iptables --flush
/usr/local/sbin/bridge.sh br0 eth0

Don’t forget to make the scripts executable:

chmod +x /usr/local/sbin/bridge.sh /usr/local/sbin/calculate-address

Install drbd:

yum --enablerepo=elrepo install drbd kmod-drbd83

Make sure that a root .ssh directory.  You can do this either by making the directory, or just sshing to another system.

Add a drbd.conf file to /etc/modprobe.d as follows:

echo "options drbd minor_count=128 usermode_helper=/bin/true" >/etc/modprobe.d/drbd.conf

Install kvm:

install kvm python-virtinst

and some other packages:

yum --enablerepo=elrepo install kmod-drbd83
yum --enablerepo=epel install pyOpenSSL python-simplejson pyparsing python-inotify python-ctypes python-pycurl python-paramiko debootstrap socat
The volume group is required to be at least 20GiB.

If you haven’t configured your LVM volume group at install time you need to do it before trying to initialize the Ganeti cluster. This is done by formatting the devices/partitions you want to use for it and then adding them to the relevant volume group::

  pvcreate /dev/sda3
  vgcreate vmvg /dev/sda3

or:

  pvcreate /dev/sdb1
  pvcreate /dev/sdc1
  vgcreate vmvg /dev/sdb1 /dev/sdc1

Finally, download and install Ganeti:

wget http://jfut.integ.jp/linux/ganeti/noarch/ganeti-2.4.2-1.el6.noarch.rpm
wget http://jfut.integ.jp/linux/ganeti/noarch/ganeti-instance-debootstrap-0.7-2.el5.noarch.rpm
rpm -ivh ganeti-2.4.2-1.el6.noarch.rpm ganeti-instance-debootstrap-0.7-2.el5.noarch.rpm

At this point, Ganeti is installed.  The final step is to fix an SSL error by regenerating the certificates:

openssl req -new -x509 -days 1825 -keyout server-key.pem -out server-cert.pem
openssl rsa -in server-key.pem -out server-key-nopass.pem
cat server-key-nopass.pem server-cert.pem > /var/lib/ganeti/server.pem

openssl req -new -x509 -days 1825 -keyout rapi-key.pem -out rapi-cert.pem
openssl rsa -in rapi-key.pem -out rapi-key-nopass.pem
cat rapi-key-nopass.pem rapi-cert.pem > /var/lib/ganeti/rapi.pem

and finally start Ganeti:

service ganeti start
gnt-cluster modify --hypervisor-parameters kvm:kernel_path=
Filed in Administration, Building packages, Linux Installations, Open Source
2,224 views

ZoneMinder and the Foscam FW8918W

By jbayer - Last updated: Thursday, May 12, 2011

Following up on my earlier post about Zoneminder, I recently got a Foscam FW8918W camera.

After doing a bit of research, I found a module for Zoneminder designed specifically for this camera on another blog, durdle.com.

The page is:  zoneminder-control-module-for-foscam-fi8918w

Filed in Open Source • Tags:
1,345 views

PBX-in-a-Flash (and Linux) Network Driver Problem

By jbayer - Last updated: Friday, April 22, 2011

I recently installed PBX In A Flash on an Intel D525 Atom board, with an on-board 8168b NIC.  I had a problem where the phones would just stop for 1-5 seconds, and then continue.  I was able to track it down to the NIC which CentOS installed.

CentOS installed the driver for the RealTek 8169, which work just enough to fool you into thinking that it’s ok, but every once in a while just stops for a few seconds.

I’ve seen this same behaviour for Ubuntu Linux as well.

To identify the problem, log on and get to a command prompt, then type:

lspci

Look for a line which indicates an ethernet card, and note which card it is.  If it is a RealTek 8168b, then issue the command:

lsmod | grep 816

to see which driver is installed.  If you see a line which begins with:

r8169

then you have the problem.

To replace the driver:

I’ve uploaded the current driver here:

  r8168-8.023.00.tar.bz2 (58.5 KiB, 426 hits)

or, if you want to get it direct from the manufacturer, ho to the this link to download the driver:

As of today, 4/22/11, I used the following command to get the file.  I suspect this may not work for more than a day or so, so if  it doesn’t, then use the page linked to above to get to the download page:

 wget ftp://WebUser:pGL7E6v@207.232.93.28/cn/nic/r8168-8.023.00.tar.bz2

The following commands will untar the file, compile and install the driver, assume the file name hasn’t changed:

tar xjf  r8168-8.023.00.tar.bz2
cd r8168-8.023.00
./autorun.sh
reboot
Filed in Administration, VOIP
773 views

Home network upgrade time!

By jbayer - Last updated: Monday, April 18, 2011

It was time again to revisit my home network.  When I looked at it, I saw that I had the following:

1 firewall system running Smoothwall
1 wireless router
1 file server running FreeNAS
1 Atom D525 system running Asterisk

as well as the computers which used the network.  Because of the way the apartment is set up, the firewall, phone system, file server and wireless router were all in my living room.  While the systems were all mini-ITX systems, there was still enough of a fan noise to be noticable when it was quiet, as well as the extra electricity being used.

A number of years ago I learnt about DD-WRT, which is a free replacement firmware/software to replace the firmware of many wireless routers.  At the time I was using a Linksys wrt54g, and tried using it, but was unimpressed due to the limitations of the router and the early development level of DD-WRT.  I have kept hearing about it over the years, and decided to take a second look at it.

What I found was a highly-professional firmware based on Linux, which included a ton of stuff, as well as additional packages which could be downloaded and installed.  Also, the hardware has improved over the years, both with faster cpu’s, more memory, and overall better quality.

I looked at the available wireless routers, looking for one with the following abilities:

Maximize RAM and NVRAM
All current wireless protocols supported: a/b/g/n
4 or  more network ports, preferably gigabit
USB port for external hard drive
Ability to use latest version of DD-WRT

and a reasonable cost.

I settled on the Buffalo WZR-HP-G300NH, which has 64 meg ram, 32 meg nvram, 4 network ports plus the WAN port which can be configured to be a fifth LAN port, all gigabit, and a USB.  There are others equally as good.  One reason I chose the Buffalo is that Buffalo provides a re-branded version of DD-WRT specifically for this router.  This tells me that there would be very good support for DD-WRT from many places.

Rather than repeat already-existing instructions, I’ll be providing links along with a short comment about it.

First I had to install the DD-WRT firmware.  Apparently it is somewhat specific to each chipset; for this router I used this: WZR-HP-G300NH.  Nothing special about the flashing, you essentially download a binary and flash it.  When done, you have DD-WRT installed.  Very easy to do.

Now that I had DD-WRT installed, I had to configure it so that it is a bit more like a Linux box.  The problem with these routers is that quite often the NVRAM/filesystem is read-only, making it very difficult to make any changes or updates.  Now is when an external drive becomes very useful, even if you aren’t going to use it as a file server.  You can use any USB storage device, including a flash drive, hard drive, etc.  Since I’m using this as a file server, I plugged in a 1 terabyte drive, after first formatting it with the EXT3 filesystem.  If you don’t have a Linux box to do the formatting, you can use a bootable CD, such as GParted.  While not necessary, I recommend that you partition the disk to create the following filesystems:

Partition Table
Partition # Filesystem Size
1 ext3 500 meg to 1 gig
2 swap 128-256 meg (optional)
3 ext3 (NAS data, this is the space that Samba will share)

Now I was ready to install some additional software.  I followed the instructions on this page: Howto Install Optware on Atheros units.

My old router supported OpenVPN, to allow me access to my network from the outside.  So I now followed these instructions, with the following minor changes:

  1. Ignore the section labelled:    Getting Started – Flashing the Router
  2. I created my certificates on a Linux box, so I ignored the section labelled:  Creating Certificates Using Easy RSA in Windows

Problems with OpenVPN are beyond the scope of this article;  if you have problems, try looking in the Openvpn site.

One problem with DD-WRT is  that the port forwarding page is more limited than I like.  I have a number of specific IP addresses which I forward ports to my internal phone system, and I couldn’t do this in DD-WRT.  So I write a small script which would run at startup to implement these specific port forwards. I used this page as a reference, and the script is as follows; all internal and external IP addresses have been changed to protect the innocent (script updated 5/25/2011):

#
# This is written for the BusyBox shell implementation, which doesn't have
# arrays.  Simulate them using variables which only differ in the
# number, as follows:                                                                                 

r1="1.2.3.4/32,tcp,5060:5082,192.168.2.150"
r2="2.3.4.5/32,tcp,4569,192.168.2.150"
r3="3.4.5.6/32,tcp,5060,192.168.2.150"
r4="4.5.6.7/32,tcp,5060,192.168.2.150"
r5="5.6.7.8/32,udp,5060:5082,192.168.2.150"
r6="6.7.8.9/32,udp,4569,192.168.2.150"
r7="7.8.9.10/32,udp,5060,192.168.2.150"
r8="18.9.10.11/32,udp,5060,192.168.2.150"                                                           

NUMLINES=8
index=1
rm -f /tmp/root/iptables.log
while [ $index -le $NUMLINES ]; do
eval r=\$r$index
if [ "$r" != "" ]; then
ip=`echo $r | cut -f 1 -d","`
protocol=`echo $r | cut -f 2 -d","`
ports=`echo $r | cut -f 3 -d","`
dest=`echo $r | cut -f 4 -d","`
iptables -t nat -I PREROUTING -p $protocol -s $ip  -d $(nvram get wan_ipaddr) --dport
iptables -I INPUT -p $protocol -i eth1 --dport $ports -j logaccept
iptables -I FORWARD -p $protocol -d $dest -s $ip --dport $ports -j logaccept
echo " " >>/tmp/root/iptables.log
fi
index=$((index+1))
done
index=1                                                                                              rm -f /tmp/root/iptables.log                                                                         while [ $index -le $NUMLINES ]; do                                                                           eval r=\$r$index                                                                                     if [ "$r" != "" ]; then                                                                                      ip=`echo $r | cut -f 1 -d","`                                                                        protocol=`echo $r | cut -f 2 -d","`                                                                  ports=`echo $r | cut -f 3 -d","`                                                                     dest=`echo $r | cut -f 4 -d","`                                                                      iptables -t nat -I PREROUTING -p $protocol -s $ip  -d $(nvram get wan_ipaddr) --dport                iptables -I INPUT -p $protocol -i eth1 --dport $ports -j logaccept                                   iptables -I FORWARD -p $protocol -d $dest -s $ip --dport $ports -j logaccept                         echo " " >>/tmp/root/iptables.log                                                            fi                                                                                                   index=$((index+1))                                                                           done

Now that I’ve taken care of my security, I need to get Samba working.  Luckily, Samba is already installed in the basic DD-WRT package.  This page contains the information, but I had to make the following changes:

  1. I added additional users to the passwd and group file to support my existing users, using the same group and uid numbers.
  2. I ignored step 4, and instead added the samba command to the startup commands.

DD-WRT uses DNSMasq instead of bind.  Not being familiar with DNSMasq, I followed this page to set it up.  The page details several different ways to set up DNSMasq, I used step 4, and modified the script to reflect my installation.  When done, I added a call to it in the startup commands.

Finally, I needed a way to backup all my data, so I installed rsync.  This page details it, but I had to change the procedure slightly as follows:

  1. Replaced calls to
    /opt/bin/ipkg-opt

    with

    /opt/bin/opkg
  2. Replaced startup of rsync daemon with call in startup script:
    /opt/usr/bin/rsync --daemon --config=/opt/etc/rsyncd.conf

Finally, I’m done for now.  I’ve decided to keep my phones on a separate box, but this little wireless router plus an external hard disk, for a total cost of around $100, is replacing two mini-ITX systems which each would cost about $150-$200 to replace.  Additionally, I’m getting the advantage of reducing the noise level in my apartment, reducing my electricity usage, and gaining some additional functionality.

Filed in Administration, Linux Installations, Open Source
1,073 views

Old memories (retirement of an old Xenix system)

By jbayer - Last updated: Tuesday, April 12, 2011

Back in 1980-1985, I wrote some software for employment agencies;  it was an early database back when no one knew what a database was.  It was originally written to run on an Apple ][ with dual floppy drives, and had lots of optimisation to minimise the amount of space used on disk.  Eventually we moved to am Apple ///, and then on to a PC.  Eventually we moved to SCO Xenix to gain the ability to have multiple users accessing the database;  Xenix at the time was running on an 80286.  This was at a time when Microsoft said that you couldn’t multitask or have multiple users on those systems, we had some customers with up to 32 terminals all running on the same system.  Once we had moved to Xenix, we sold a number of systems to some fairly large employment agencies and even one insurance company.  When SCO stopped selling Xenix and started selling Unix, the software ran on SCO Unix without any problems or changes needed.  It also ran on PC-DOS & MS-DOS.

We were fairly successful for a while, and were in business for about 10 years, until 1990.  By then much larger firms were moving into the business with resources we weren’t able to match.

In 1999 I updated the software to take the Y2K problem into account, and the existing customers continued using the software without any problems;  the only calls I was getting was for minor enhancements.

Over the years our customers either went out of business, were taken over, or in a few cases, eventually moved to a new, modern software package.  But I still had two customers who were using the software until this year!  Because I’ve provided support over the years I’ve kept one development system in storage, an old 80486 running both SCO Xenix and SCO Unix.

Finally, however, I received word that my last customer is no longer using the software.  So I decided to capture the data from the Xenix system and move on.  Boy, what a trip down memory lane;  Xenix didn’t have network software initially, and I never purchased the networking software for it, so here I had a computer, with 4 meg of memory and a 200 meg hard disk, which I have no real access to.  The disk was so old that modern motherboards weren’t even able to recognize it, and Xenix is so old that it cannot access any modern hard disk due to the size.  So I was finally reduced to setting up a null-modem cable between the old Xenix system and a spare Linux box, running minicom on Linux and transferring the data over the serial cable…..at a baud rate of 38400, which equates to about 3000 characters/second after error checking is done!  It’s in progress right now, and will take a few days before I’ve transferred everything I need.

My software package was called:  The Matcher, and was written initially in UCSD Pascal on the Apple, then ported to Microsoft Pascal on the PC.  MS Pascal is an ISO compliant compiler, there were a number of changes I needed to make, but overall the porting process took less than a week (if my memory is correct, it was a looonng time ago!).  The advantage to the MS compiler was that it compiled the exact same code on DOS and Xenix, without any syntax changes.  I’m not a fan of Microsoft, and the compiler was not too well documented, but it worked perfectly!

I may try and compile it with Free Pascal, just to see if I can.

This page is a tribute to a software package that was in use for 30 years!  Yes, I am tooting my own horn, if you will, and yes, it was running on an ancient OS and computer; but it ran, and was used productively for all this time.  Say what you will, but before you do, show me another software package which can say the same.  There aren’t many.

JBB

Filed in Administration
6,370 views

Setting up a secondary High-Availability Asterisk server

By jbayer - Last updated: Wednesday, April 6, 2011

Congratulations!  You have now set up your first Asterisk-based VOIP server.

Next question (probably the first your boss will ask you):  What happens when the server crashes, or loses power, or needs to be upgraded, or…….;  well, you get the idea.  If you only have a single server, you lose your phones until it is rebooted.  Given that you probably installed this on a cheap, inexpensive piece of hardware, these questions are not out of the question, especially for a business.

We had the same questions, and have implemented a failover solution.  I started with a script I got from this web page, but was dissatisfied with it.  It seemed to be a bit of a kludge, in that it wasn’t a true HA solution, but was only a backup solution.

I did a massive reworking of the script, and the result downloadable from here (revised 6/15/11, now version 1.3):

  flip1405.sh (21.2 KiB, 1,712 hits)

This script is used to synchronize the /tftpboot with the /var/ftp/ directory:

  syncftp.sh (1.6 KiB, 0 hits)

The only dependencies for Flip1405.sh are nmap and arping

To use, first get your primary Asterisk server running smoothly.  When ready, you can either clone it using Clonezilla (or some other utility) or just install Asterisk on the second box.  Then follow these steps:

  1. Setup shared-keys so the servers can copy between each other without user intervention. Setup Login without password
  2. Set up ftp (I use vsftp), if needed.  We use it to download the configurations for the Aastra phones.  Usually we would use tftp, but since we have some phones outside our office we simply use ftp for everything.
  3. Install this script into /usr/local/sbin on the primary/active system.
  4. Run the script with the  -s option:
    /usr/local/sbin/flip1405.sh -s
  5. The second script:  syncftp.sh, is used to synchronize the /tftpboot directory with the /var/ftp directory.  If you need it, install the syncftp.sh script into /usr/local/sbin
  6. Open up the flip1405.sh in an editor, and check the various settings.  I would recommend that if you need to change them, to use a config file (/etc/sysconfig/flip1405) rather than editing each file.  The config file is NOT sync’d between the systems, so you  can have system specific options in the file.
  7. There is no need to specify the device, or whether the system is a master or slave.  The script determines this at run time.  The most important lines to set are the first three variables:   MASTERIP, SLAVEIP, and FLOAT.  These are:
    1. MASTERIP     IP address of the master system (arbitrary name)
    2. SLAVEIP        IP address of the slave system
    3. FLOAT          IP address that will float between the Master and Slave, and which your phones will access
  8. All other variables are set for an Elastix system.  Elastix is based on the following:
    Asterisk 1.6
    Centos 5.5
    FreePBX 2.6
  9. Make sure to set the bindaddr to the virtual IP address in /etc/asterisk/sip.conf or
    /etc/asterisk/sip_general_custom.conf 

    bindaddr=192.168.1.12 ;IP of Virtual interface
  10. Add the following line(s) to the root crontab (only install the syncftp.sh line if you are using it):
    * * * * *     /usr/local/sbin/flip1405.sh
    */5 * * * *	/usr/local/sbin/syncftp.sh
  11. If you like, you can add the following lines to /etc/crontab instead:

    * * * * *     root /usr/local/sbin/flip1405.sh
    */5 * * * *	root /usr/local/sbin/syncftp.sh
  12. If you want to automatically rotate the logs, add the following file:

/etc/logrotate.d/flip1405:

/var/log/flip1405.log {
 missingok
 notifempty
 sharedscripts
}

If you have phones outside your network, you will need to configure your firewall to direct the following ports to the FLOAT address:

tcp 21 (if you are using ftp)
tcp 3000
udp 3000
tcp 5060-5082
tcp 10000-20000
tcp 5800-5900
udp 5060-5082
udp 1000-20000
udp 5800-5900

Filed in Administration, VOIP
1,736 views

Remove/reconfigure an Aastra phone from an Asterisk/FreePBX installation

By jbayer - Last updated: Wednesday, March 23, 2011

During my initial setup and configuration of our new VOIP system, I had to remove a phone from the system several times.  After doing so several times, I have been able to remove a phone in less than a minute.

To totally remove an Aastra phone from an Asterisk/FreePBX configuration, you need to remove the following files:

/tftpboot/mac_address.cfg
/var/cache/aastra/old_exten.context

and then edit the file:

/var/cache/aastra/startup_asterisk.cfg

and delete the section which referred to the old device.  The file contains a section for each device which has been registered with the system, each section is started with the device id surrounded by brackets.

If you are also using FTP to support your phones, you will need to delete the same files from the ftp directory.

Finally, restore the phone to factory defaults

Filed in Administration, VOIP • Tags:
1,424 views

Setting up a VOIP server, part 5 (Weather by Zip)

By jbayer - Last updated: Wednesday, March 23, 2011

I wanted to have the feature available to get the weather by zip code, so I tried to install the Weather by zip code module.  There is a deplorable lack of documentation on the steps needed to install this.  As usual, this article documents my experiences with Elastix, but since Elastix uses FreePBX this should be applicable to most systems.

There are three main steps involved in getting this to work.  They are:

  1. Install Flite
  2. Install Asterisk-Flite
  3. Install Weather by ZIP

The following files are needed:

weatherzip-1.1.7.tar.gz
flite-1.4-release.tar.gz
Asterisk-Flite-1.6-0.1-beta2.tar.gz

Step 1:  Download, compile and install Flite.  Log on to the system, and issue the following commands (cut ‘n paste will probably work):

cd /usr/src
wget http://cmuflite.org/packed/flite-1.4/flite-1.4-release.tar.gz
tar xzf flite-1.4-release.tar.gz
cd flite-1.4-release
./configure --enable-shared
make
make install

If you are on a 64 bit system, then you may need to do the following step:

mv /usr/local/lib/flite* /usr/local/lib64

You now need to update the dynamic linker.  Depending on your system, you will need to do one of the following.  Replace the “lib64″ with “lib” if you are on a 32 bit system:

Edit the file /etc/ld.so.conf, and add the following line:

/usr/local/lib64

or

Create a file /etc/ld.so.conf.d/local-lib.conf, and have the following line in it:

/usr/local/lib64

then issue the command:

ldconfig

Step 2:  Download, compile and install Asterisk-Flite

cd /usr/src
wget http://cloud.github.com/downloads/zaf/Asterisk-Flite/Asterisk-Flite-1.6-0.1-beta2.tar.gz
cd Asterisk-Flite
make
make install

if you are on a 64 bit system, then you may need to do the following step:

mv /usr/lib/asterisk/modules/app_flite.so /usr/lib64/asterisk/modules

Step 3:  Install the weatherzip module in FreePBX

Step 3.1: Download the module to your desktop From here..

Don’t decompress the archive!

Step 3.2: Use a web browser to access FreePBX on your PBX. Choose Tools, Module Admin, Upload Module.

Step 3.3: Now, browse to the weatherzip-1.1.7.tgz file on your Desktop and click the Upload button. Now click local module administration, scroll down and click on Sys Info and then the Install radio button. Now click Process, and complete the usual FreePBX install and reload process.

Step 3.4: I had one problem with the Weather by Zip module.  The PHP file references  a function xml2array, which isn’t present.  Since it is used only to display the module info, it is safe to comment it out.  Open up the file:

/var/www/html/admin/modules/weatherzip/page.weatherzip.php

and add to forward slashes to the beginning of line 23

Step 3.5: Finally, go into the FreePBX admin page for the Weather by Zip module, and make sure that the flite engine is selected.

Finally, restart Asterisk:

amportal restart

You should be able to test by dialing:  *947  from any phone and following the prompts.

References

Installing_Weather_by_ZIP_Code_Module_for_FreePBX

http://asterisk-flite.sourceforge.net/

http://projects.colsolgrp.net/attachments/download/342/weatherzip-1.1.7.tgz

Filed in Open Source, VOIP • Tags:
6,251 views

DHCP and TFTP servers

By jbayer - Last updated: Tuesday, March 22, 2011

TFTP servers are used to provide configuration files for local systems.  An easy way to tell systems the address of the tftp server is to use DHCP option 66.

DHCP can provide quite a lot of information when it provisions an address.  For a complete listing, go to this link, however all we are concerned with right now is option 66, which is what is used to specify a tftp server address

The dhcpd daemon which is supplied with most Linux distributions take the following syntax.  The following fragment specifies the tftp server to be at address 192.168.30.12, a router and name server to be at 192.168.30.1, and a pool of address 192.168.30.75-115 for systems to get addresses from.

option tftp66 code 66 = string;
subnet 192.168.30.0 netmask 255.255.255.0 {
  option tftp66 "192.168.30.12";
  authoritative;
  option routers 192.168.30.1;
  option domain-name "localnet.net";
  option domain-name-servers 192.168.30.1;
  pool {
    option routers 192.168.30.1;
    range 192.168.30.75 192.168.30.115;
  }
}
Filed in Administration, Open Source • Tags:
asd