PostgreSQL, Raspberry Pi, Debian: Locale issues

With the latest “Jessie” Wheezy Debian release on my relatively new R-Pi 2, I was in a hurry to replace my R-Pi original after it failed with a SD card error. Fortunately I was able to recover the config files from the original, as my backups were very much out of date. This system is mail dhcp, dns, mail and asterisk server and it didn’t take a huge amount of time to get everything back together (and faster, too!) but in my haste I did not configure the locale (or the filesystem expansion) in the GUI before I started installing things and got caught with a complaint from PostgreSQL when I tried to connect to the database that it was created with a locale (the default which is Great Britain) instead of the Canadian locale which I’d later configured it to.

Trying the easy stuff first, I removed PostgreSQL and re-installed it but no dice. What worked was the following.

  1. Change directory to /var/lib/postgresql
  2. Remove the 9.4 directory and all of its subdirectories and files with rm -rf 9.4
  3. Log in as user postgres.
  4. Initialize with initdb (I had to locate the executable as it wasn’t in the default path) with the path 9.4/main/ to recreate the master database (i.e. initdb -D 9.4/main/)
  5. Restart postgres

Voila! I am now able to connect.

Advertisements
Posted in Uncategorized | Tagged , | Leave a comment

Status of the Linux Ham Blog

Oh well. Best intentions and all that. Not about writing this blog. It was meant to be sporadic at best, but about using Linux in ham radio. Not that I’m totally devoid of Linux in the shack. I have a pair of Raspberry Pi that run Linux. One does all my household serving, including phone switch (Asterisk), email server (Postfix/Dovecot), DHCP (dnsmasq), NTP, DNS (dnsmasq), and a couple of other things that have slipped my mind. I might turn it into an Echolink/IRLP node as our club’s current ancient server is now singing with the choir eternal.

I’ve also acquired a Synology DSM1813+ which runs BusyBox Linux and have a bit of Python on it to manage my RSS feeds. It backs up my log database and keeps my archived stuff. The other Pi (model 2) is intended for use as an development environment for Atmel microprocessor projects. The build is still going on for that.

The main computer in the shack is Windows. I was already running it and there is just too much useful software that is Windows only. Some of my stuff runs on Linux, like WSJT-X and FLDIGI, but not all of it does, so there you have it. Stuck inside of Windows with the Linux blues again.

Back to writing this blog. All of my ham radio blogging is now over on the York Region Amateur Radio Club blog which is mostly written by me. It also has housekeeping stuff like meeting minutes but I try to keep interesting ham radio things in there. The blog took over from “Splatter” (a.k.a. the Splatter) which was the club newsletter. Since no-one wanted to edit it I decided that if I was going to be saddled with the task I’d make it easier and more fun and make it a blog. So if you want to read what I’m writing, I invite you to stop by.

By the way, right now and for the next 11 months I’m president of the Club like I’ve been for the past 2 years. So it is best that I support my club by writing for the common good. If someone takes over my position (as chief blogger, President, and web site maintainer) then I’ll be back here again.

Until then,

73 and good DX,

Chris VE3NRT

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Synology DS1813+ the scoop so far

So far, it’s been flawless. Since my original post on replacement I’ve added two more 4TB disk drives. They have worked perfectly so far and the system (including the UPS) has lived through several power failures that outlasted my UPS battery and resulted in a controlled shutdown. A nice surprise was that the DS1813+ plays flac files to both my Panasonic television and my Roku Soundbridge 100 despite neither of them having native support for flac.

I have enabled my home brew (Python) RSS video grabber to run nightly to bring down TED talks and other things. The problem I have with TED right now is that my Panasonic Viera TV won’t sort the DLNA video feed by date, and there doesn’t seem to be any way to tell what’s been watched before, so it’s hard to tell the old ones from the new ones. I’ll look for a way to add the date to the mp4 header. I’ve also been unable to figure out how to convert the Reuters RSS video feed (which is in h.263 format, associated with videoconferencing) to something watchable. It’s probably for the best as the feed is very low resolution (around 160×200).

My Raspberry Pi has been pressed into service as a phone switch (Asterisk with software G.729 support) and does mail, ntp, tftp, dhcp and dns services. The latter 2 are done with dnsmasq. It also does a modified version of Ned Batchelder’s green pixel web server which intercepts (thanks to dnsmasq) requests for doubleclick.net and the like to just serve a single green pixel saving time and network bandwidth.

Anyway, the device works great, and while a bit on the expensive side make a wonderful home media server that requires a minimum of fuss – quite unlike my old laptop/usb drive based RAID 6 system.

Posted in RAID | Tagged | Leave a comment

G’bye RAID 6

Well yes, and no. My RAID 6 array, which has 8 two terabyte drives all on USB dual-docks, has been nothing but trouble. I finally decided it wasn’t going to work for me unless I used a server instead of the laptop host, so I’m in the process of ditching it.

I bought a nice new Synology DS1813+. It runs Linux under the covers, 8 storage bays, 4 gigabit Ethernet ports, additional USB (2 and 3) ports, and a couple of SATA 3 ports for expansion. So far it has run flawlessly, although I also sprang for 4 four terabyte NAS drives to go with it.

I’m now moving everything over to it from the old array, and have gone with RAID 5 + Full backup instead of RAID 6 + partial backup.

This brings to mind some truths about RAID. Here’s my view…

  1. RAID is mainly about availability, not reliability. If you want your system to be available 24 x 7, you have to do something about disk failures, and RAID is a solution for that.
  2. RAID protects against disk failure, not disk error. Disk errors can still happen so quality disk drives are still important.
  3. In the spectrum of possible bad things that can happen to your files, a disk failure is one of many.
  4. I’m very suspicious of USB controllers.
  5. RAID is no replacement for backup. I know this is what everybody says, but I don’t think it can be said too many times.
  6. A UPS is a very good thing to have (and I do). Most of my data corruption problems were directory files that got messed up after a power failure.

 

Posted in Linux | Tagged , , , , , | Leave a comment

Asterisk – AGI not working from IAX

This one took me a while to figure out, so I decided to share the solution to my pain.

I have two Asterisk systems connected by IAX2. One system is behind a corporate firewall and I didn’t want to open up the inbound port. So I have it registering and qualifying from behind the firewall to my other (home) system where I have the port open for inbound connections on port 4569 from the other system’s IP address.

The trouble began when trying to make a call from the home system to the corporate system. The well-tested AGI script, written in Python, exited without doing anything. That was surprising because right after I gather up the AGI variables at the beginning of the script, I modify Python’s error class to report exceptions through AGI. So if a run-time error occurs I always see it, as long as no errors occur when the module loads.  I just use the Python interpreter to test whether the AGI module loads OK which it did.

The problem turned out to be in the reading of the AGI variables. I had used the same logic that is provided in “Asterisk: The Future of IP Telephony” – an outdated but still very useful guide. The key was this line which splits the variable into its name and its value:

key,data = line.split(':')

My code was identical. However, there is a serious flaw in it. The channel variable was IAX2/xx.xxx.xxx.xxx:4569-6395>, where all the x’s represent my home IP address. Notice after the IP address there is an extra colon. That means that the split function will make 3 parts, not 2. Not only does this deliver a bad value, but also throws a ValueError: too many values to unpack exception. As this happened before I changed the error handler to report through AGI, it simply exits without saying anything.

The corrected code is

key,data = line.split(':',1)

This ensures that the text is split only at the first colon, and not at any others. Everything started working after I made this simple change.

Posted in Asterisk, Programming | Tagged , , , , | Leave a comment

A Curious Species of Spam

Recently I’ve been receiving pharma-spam that links to a site that’s been disabled.

Viagra 60 pills 75mg – $156.00 ($2.60 per item)
Prednisolone 120 pills 5mg – $24.00 ($0.20 per item)
Retin-A 5 tubes20g/0.05% – $88.25 ($17.65 per item)
Ventolin 2 inhalers 100mcg – $39.90 ($19.95 per item)
Amoxicillin 90 pills 250mg – $58.50 ($0.65 per item)
Benicar 120 pills 20mg – $130.80 ($1.09 per item)
100% Pure Okinawan Coral Calcium 1 bottle – $34.95 ($34.95 per item)
more info

Seems really stupid to be blasting out advertising for something that doesn’t exist, and because I follow up spam email by tracking down the source through the link I’m stumped on this one.

The email headers point to gmail addresses, so I tried to report this to Google. They advise to report spam to the US Federal Trade Commission, which isn’t realistic for someone living in Canada getting spam from who knows where. So when Google asked for feedback on the page, I rated it “Not at all helpful” and made my comments.

Unfortunately, Google replies “There were problems sending your form. Please try again.” Can’t Google take criticism?

Posted in Uncategorized | Tagged , , , , | 5 Comments

Echo AudioFire 12 – False Advertising? You be the judge

About a year ago I bought an Echo AudioFire 12. The reasons I bought it were as follows:

  1. It had 8 more ins and outs – in this case 12.
  2. Balanced audio
  3. Rack mountable
  4. 192KHz

#4 was mainly because of SDR, not my refined musical sensibilities – although I use it for both purposes. Little did I know that while Echo claims 192 KHz, and also claims Windows 7 support – it cannot do both at the same time!

The release notes for the latest driver say that 192KHz is no longer supported. Yet on their  product page it still claims 192KHz with no caveat. Is this fair? Is this deceptive?

You be the judge. As for me, I find this very disappointing.

Posted in Electronics, SDR | Tagged , , , , , | Leave a comment