Friday, September 18, 2009

Trying Out Rygel

Trying out the new, integrated into GNOME and uses GStreamer -- Media Sharing daemon, Rygel.

First thoughts, it's a _lot_ easier to configure than Mediatomb -- I am using the "media export" plugin because my Ubuntu Jaunty installation is rather bastardised, so Tracker is "unreliable at best" on my system.

I'm using the packages from James Henstridge's PPA Repository -- because they're available for Jaunty, as well as the Vala Compiler from their PPA.

Getting it going with the PS3 was easy though, first of all -- I disabled the LPCM transcoding (for some reason, none of my MP3's appeared until I did that), by unchecking the tickbox -- set the interface to wlan0, added my media directory -- and away we went.

Still have the odd issue where Wirelessly, my PS3 doesn't see anything exported from the Ubuntu box -- but i'm figuring that's more a router issue, more than an Ubuntu one -- having recently experimented with Fedora as well.

PackageKit, The Superior update-manager Alternative

So, Dad decided to mess with his Ubuntu installation over the weekend -- he upgraded from Hardy to Jaunty as a one-step upgrade, which, somewhat unsurprisingly, broke heaps of stuff.

(personal opinion: It is for this reason, I hope the Ubuntu guys don't go head-long into GNOME 3.0 for "whatever-the-hell-the-L-release-is-called" if it's going to be a standard 6-month release cycle AND an LTS -- because they'll have people from 8.04 or 6.06 triggering ungrades and no-one wants a repeat of the PulseAudio debacle but on a far bigger scale. Either a) leave GNOME 2.28, continue polishing it and push GNOME 3.0 for the release after the LTS, so it gets three releases (or 2 years) of polish before it goes to the masses, or b) make the release cycle 6 months longer for an LTS, just like 6.06 was, but for the right reasons.)

Anyway, after re-installing Jaunty from scratch, fixing his RAID, re-installing his printer and playing with DKMS because his nVidia card doesn't like the newest driver in Jaunty, but will happily work with anything older -- we tripped over the 'incredible, vanishing update manager issue'.

(personal opinion II: big, big cock-up on the part of the Ubuntu guys -- Windows has an update icon, MacOSX has an update icon, every other distribution of UNIX has an update icon, but a 50+ year old man can have a taskbar full of update-manager windows, which makes the one browser window icon in the window list appear as 3-pixels wide because he doesn't understand he has to close them all individually? It would have been better to pop up a dialogue in the middle of the screen that says "Security Updates Are Available for Your Computer, would you like to install them now?" (or "Non-Essential Updates" in the case of non-security updates), or leave the icon where it was and hack in OSD notifications (like NetworkManager does) -- but don't just leave a glowing taskbar window in the bottom left hand corner, UI or Accessibility designers would turn in their graves.)

Anyway ... Given the track record that Ubuntu has for making seat-of-the-pant changes like that and taking forever to admit it was a mistake and reverting it to sensible behaviour, I decided to give PackageKit a try.

Short story -- impressive.

Installation was a simple: apt-get -f install packagekit packagekit-gnome gstreamer0.10-packagekit

The Ubuntu packages in Jaunty do add a duplicate "Update Manager" icon to the System ⇢ Administration menu, but that's purely cosmetic -- upon install it does make itself the default package update manager, which is a step in the right direction.

I have always been concerned about the way updates are presented for non-technical users, Microsoft nearly has it right -- too much information scares the non-technical user, but most UNIX variations give too much superfluous information to the user, great for technical types who actually fix issues -- and certainly something that shouldn't be removed, just 'shielded' from the user somehow).

PackageKit does this well, it gives the user notification that updates are pending in the standard way (which was our major gripe that prompted the change) but is also laid out in such a way that Dad found easier to drive than the traditional package manager (as he put it, "I already like the idea you can press a button to review changes before they happen.").

As I may of mentioned before in this blog, my dad is not a unintelligent man, he's been involved with computers, electronics, data communications, radio and just about any other form of technology you'd care to mention forever -- we've worked together on some massive projects, including hardware design, starting our own UNIX distribution and starting up smaller technology projects together -- and he has been a Linux user for nearly 5 years himself, but he's firmly a "a computer is a tool, just make the thing work" man, rather than a "let's experiment" one.

(He also builds RC Boats for a hobby, which is just cool.)

"Network Error 00000000", The PS3 and Mediatomb

After requiring a fresh install of Ubuntu on my media-serving laptop due to disc failure -- I restored all the configuration settings from a backup, re-imported my library into Mediatomb, restarted the daemon and wandered into the lounge to watch TV via the PS3, a ritual with the two evening coffees before the cricket starts.

However, last night -- something strange kept happening, I could browse the videos, they even had thumbnails, but when I attempted to play them, a black screen would appear with "Network Error (000000000)".

Checked the configuration, checked the router settings, checked the wireless signal strength, all fine. (then figured, "paul, you'd not be able to see anything if these settings didn't work ;)")

Googled, no luck there either -- hence this post.

Enabled debugging mode by editing the /etc/default/mediatomb file and changing OPTIONS="" to OPTIONS="-D" and restarted the daemon and loaded up the /var/log/mediatomb.log file to find:



2009-09-17 23:34:00 DEBUG: [../src/io_handler_buffer_helper.cc:224] staticThreadProc(): starting buffer thread... thread: -1267590256
2009-09-17 23:34:02 DEBUG: [../src/process_io_handler.cc:234] read(): process exited with status 256
2009-09-17 23:34:02 DEBUG: [../src/io_handler_buffer_helper.cc:227] staticThreadProc(): buffer thread shut down. thread: -1267590256



Hmm, status 256 you say? "Could be something to do with the encoding then?" I thought.

Running ffmpeg -i testvideo.wmv -target dvd -y testvideo-ps3.avi from the command line, indeed gave me my answer:



Unknown encoder 'mpeg2video'



Turns out, the default ffmpeg installation for Ubuntu Jaunty and Karmic have mpeg2video support in ffmpeg disabled.

Two ways to fix this, the first is to implement a much, much, much longer command to encode your videos -- I use a generic script to encode videos based on their content type, but the PS3 can play (from Firmware 2.61, 3.00 and 3.01 anyway) anything encoded with the DVD profile (which encodes to MPEG2 based AVI's via the aforementioned mpeg2video codec), so instead of:

ffmpeg -i "$input" -target dvd -y "$output"

You'd use:

ffmpeg -i "$input" -vcodec mpeg1video -mbd rd -trellis 2 -cmp 2 -subcmp 2 -b 1500 -g 250 -y "$output"

(note: those commands are the only ones that are essential for making the video output work on the PS3, it'll produce a standards-compliant MPEG file with 64k MP2 audio -- but the quality may look suspect, as long as you leave those commands in, you can add things like "-flags qprd", "-bf 2" or "-flags +ilme+ildct" (good for interlaced video like animation) to improve the quality slighly)

Or, you can install the alternative versions of FFMPEG by enabling the multiverse repository (System ⇢ Administration ⇢ Software Sources) and then installing the -unstripped versions of FFMPEG with the command:

sudo apt-get -f install libavcodec-unstripped libavformat-unstripped

... and continue using the transcoding scripts you're using now :)

How can I tell if I have a broken FFMPEG installation?



The simplest way is to run: ffmpeg -formats | grep mpeg2video from the command line, if you receive:



D VSDT mpeg2video



Then you're missing the 'E'ncoding aspect of the codec, meaning you need to install the unstripped packages to make everything work correctly.

If it returns:



DEVSDT mpeg2video



Then you're all set to go :)

Tuesday, August 11, 2009

Getting iPod's Working With Banshee In Ubuntu 8.04.3

Recently, I had need to install a newer Banshee from the Ubuntu PPA on a friend's Ubuntu LTS machine (I only ever recommend LTSes to friends converting from Windows and thus not used to the 6-month upgrade dance).

He plugged in his iPod, after it had been restored with iTunes from his wife's PC and -- no, nothing happens.

Unplugged, Replugged -- yep, appears on the desktop as an iPod and Banshee starts correctly, the iPod just doesn't appear in it.

Checked dmesg, yes, the device is a 8GB iPod, no it does not need fsck'ing and yes, it uses the correct mountpoint.

Checked Synaptic, all the Banshee code is there.

Checked the Bugtracker, found bug #139226.

So, we ran:


sudo apt-get install podsleuth


Unplugged, Re-plugged the iPod. Success.

Question is, if podsleuth is that important to getting DAP's working in Banshee, shouldn't it be at a dependency of the install?

Thursday, July 9, 2009

Fixing Ubuntu PPA (Personal Package Archives) Signing Key Issues

My default /etc/apt/sources.list.d/ has around 10-12 PPA listings in it all the time and with the release of 9.04, there doesn't seem to be an automatic way of ignoring authentication for packages on upgrades, so a number of upgrades choke because of unsatisfied authentication issues.

This thread was a lifesaver, download the script, install the dependencies, run it, then re-run sudo apt-get -f update ... problem solved!

Wednesday, June 10, 2009

Why No Linux Installation has an 'I Only Speak One Language' Option?

Now that Fedora 11 has come out, I decided to give it a spin in a VMWare box -- i'm not entirely satisfied with the drive read speed of Ubuntu Jaunty, nor the compiled in IPv6 option making Transmission crawl into the floor in terms of connection speed with no true way to disable it, I am unsure if users will the new 'update notification' (it's almost like Windows XP in that regard, just without the forced rebooting when it's finished) and I can certainly take or leave the 'new' notification system, which makes VMWare go nuts with screen flicker while the notification is on-screen.

Needless to say, that while I thought Ubuntu Hardy was brilliant for both technical professionals and new users alike on the Desktop -- having used Jaunty for a month, I almost feel like i've installed a totally different system that feels totally foreign -- and one that has been dumbed-down to the least-common-demoninator level, an unfortunate side-effect of 'visionary progression' within parts of the Linux on the Desktop supporters.

Coupled with the fact i'd like to play with RPM building again and thought PackageKit sounded remarkably cool -- I thought this would be a good time to try Fedora (my last experience with it on the desktop was 4, other than building libgpod for 9 and 10) -- I only upgraded from Ubuntu 8.04 to 9.04 to try GNOME 2.26, which Fedora 11 has included.

Now, i've never, ever, ever accepted the defaults for a Linux installation -- so I selected the 'Customise Now' button to remove the packages I didn't need at install-time (F-Spot, Java, etc).

Fedora, like RHEL still has a very nice package selector, with an 'Optional' button that allows you to select with tick-boxes which packages the user would prefer.

So, after a while -- I found the Base section.

The Package Selection Dialogue

28 of 80 Fonts?

So I click the "Optional Packages" button, to find:

The 'Optional Packages - Fonts' Dialogue

Now, in my personal case -- as far as foreign languages go, I speak semi-minimal German. As a native English speaker, everything I do with a computer is in English, aside from seeing what the other fonts look like, all they really do for me is take up room and slow OpenOffice down when it loads.

I de-selected all the optional fonts with the exception of the DejaVu fonts and continued on with the install as normal.

I personally think that the internationalisation of Linux is incredible and a wonderful thing to watch, but installing over 100 megabytes of fonts that I will never use, never see and couldn't really understand anyway -- seems like 100 megabytes of space that could be better used elsewhere.

To be fair, On the Red Hat / Fedora side, this problem bugged me more back in the pre-Red Hat 9 days, where ISOs were shipped on a 650M CDROM and every piece of space had to be meticulously accounted for -- they've worked around the issue by using multiple CDs to do the install, as well as supplying an 'Everything on DVD' release.

Ubuntu, on the other hand -- has always had this problem, Epiphany (the GNOME based Web Browser Front-end) needs to be installed post-install, but South African English, several Thai and Indian dialects as well as Japanese fonts are installed from the core 700 megabyte ISO.

It just seems as though the installer needs a box that asks 'Is that the only language you speak?' ... and only if you select 'No' does it select the internationalisation components of whatever distribution you're running.

The one question it raises is how much of all the languages you should include by default -- since the advent of network-based installs, it might work if the various installer code provided the strings for 'Do you Speak ...' 'Is your Network Set Up (followed closely by 'How would you like your network set up' if you have a Wireless configuration) and then sent off to mother-goose to install the relevant packages based on the locale configuration to that point.

Sunday, May 17, 2009

Trials with RecordMyDesktop

I've been playing with recordmydesktop lately in order to put some suitable screencasts together for demonstrating various Linux-related activities to university students next week.

Unfortunately, both Fedora 11 and Ubuntu Jaunty have issues with RecordMyDesktop -- the current version (0.3.8.1) is much better than the last version I tried (0.3.5) in terms of both video and audio quality, but the more-than-occassional



Broken pipe: Overrun occurred.



Cause audio to be clipped rather badly.

The default settings make the video speed up and therefore finish well before the audio too -- so I set about trying to find the optimium settings to make the best encode I could.

First, if you are using a 3D Window Manager (such as Compiz), please use the --on-the-fly-encoding and --full-shots options, or everything from opening new windows to redrawing your background will end up with corruption.

If you do not know which Window Manager you are running, you can use the Visual Effects tab of the Appearence Preferences window.



If the button is in the first box (None) then you are not running a 3D Window Manager, if it is in either the Normal or Extra boxes, you are.

Now we've figured out if we need the options for 3D Window Management, it's time to move on to the audio -- in it's default configuration, the program will clip and/or drop audio because of the overrun mentioned above, but you can reduce that by a fair proportion by either:


  1. Using pasuspender to launch the program. This particular solution was suggested by an Ubuntu developer on a reported bug about RecordMyDesktop that looks very similar to the particular issue we're covering here.

  2. Configuring an .asoundrc file to use PulseAudio for all ALSA based audio by default.


The latter is done by creating a new blank file in your home directory and adding the following code:



pcm.!default {
type pulse
}

ctl.!default {
type pulse
}



Save the file, exit, log out of your session and login again.

This alone reduced the dropped audio from 7 occassions in one minute's worth of recorded footage to 3.

The former is done by adding: pasuspender -- to the beginning of the command line.

On my laptops, using pasuspender made no real difference to the problem, which is why we're preferring the .asoundrc solution for the remainder of this discussion.

Another thing that helps lower the frequency of audio dropouts is to increase the buffer size used by RecordMyDesktop -- the defaults are 4k, raising that to 16k helps dramatically, but any higher doesn't seem to offer that much of an improvement (I tried 32k (32769) and 64k (65538) when testing -- i'm only recording two channels on an internal microphone though, your milage may vary)

You can do this by adding the --buffer-size 16384 option to the command line.

update (2009-05-17): At the highest quality audio and video settings, 16384 can still cause dropouts, so 65538 is now preferred.

Next, if you're using onboard audio (like Altec Lansing laptop audio) you may see:



Playback frequency 22050Hz is not available...
Using 44100Hz instead.
Recording on device hw:0,0 is set to:
2 channels at 44100Hz



The Altec Lansing Audio, as well as several other Intel based sound cards that use the hda-intel-audio driver, will resample 44100Hz input to 48000Hz, hence the error.

To fix that, you pass --freq 48000, which allows recording of audio without any extra resampling.

Now, if you've used the pasuspender solution above, or your audio seems to be correctly synced, you can move on to the next section.

If, on the other hand -- you still see Buffer Overrun errors, or your audio is out of sync, or you use my .asoundrc solution above, you'll need to pass an additional audio-related option on the command line:

-device plughw:0,0

Using plughw, allows ALSA and PulseAudio's internals to handle all of the resampling work -- or endian-conversion work automatically, which reduces a painfully large ALSA configuration that will differ on every soundcard on the market, to a single configuration change for our purposes.

The 0,0 (aka. use the first detected virtual sound device) should be fine for almost everyone working on a standard configuration -- if you've got:



You may have more than one plughw device to choose from -- choosing which one is beyond the scope of this article though.

Now we can move onto improving the video quality.

Next, it helps to set the framerate -- i've seen numerous articles on the web about this, everyone suggesting everything from 10fps to 90fps to get a clear picture.

I tried 10, 12, 20, 25, 29, 50 and 60 (these seem to be the ones that are mentioned the most, in a four page Google search on the subject) -- 10 works if you want to keep the filesize low, but the playback video seems too jerky -- 60 doesn't increase the filesize, but does have an unwanted side-effect of the video finishing well before the audio when you play it back.

The optimum setting I found was --fps 20.

Finally, because I wanted to re-encode these for different purposes, I like to do the initial encoding with the highest quality possible.

However, the difference between -v_quality 1 and -v_quality 63 was minimal at best on my 1280x800 resolution.

Somewhat obviously though, the -v_bitrate option makes A LOT of difference, so I bumped that to the highest number available (2000000).

The recommended command line(s)



I've provided both a high and low quality setting for those people who are interested

The final command line, that works for me and provides the highest quality, lowest distortion with no dropouts -- was:



recordmydesktop --on-the-fly-encoding -v_quality 63 -v_bitrate 2000000 -s_quality 10 --full-shots --fps 20 --freq 48000 --buffer-size 65538 -device plughw:0,0



For a smaller filesize or for encoding on older or busier machines, with quality suitable for downloading or streaming, you can use:



recordmydesktop --quick-subsampling --on-the-fly-encoding -v_quality 10 -v_bitrate 50000 -s_quality 1 --full-shots --fps 10 --freq 48000 --buffer-size 16384 -device plughw:0,0



This option does the encoding after the video capture has stopped, which results in a smaller filesize at the expense of taking longer to encode your original footage, you can offset this somewhat by adding the --quick-subsampling option to your command line, which saves CPU time by discarding extra pixels when calculating the chroma values during the encoding process.

note: If you are using a 2D Window Manager (such as Metacity), you may omit the --full-shots option, which halves the filesize on my Ubuntu Jaunty Jackalope install.

Why No Examples?



Google doesn't support Theora based videos to be uploaded to Blogger, I had two videos recorded of 10 seconds each, the low quality one (using the settings above) clocked in at 220 kilobytes, the high quality one was 1.3 megabytes.

When El Goog does decide to allow Theora based videos on Blogger, i'll post them -- but converting them to .mp4's just to show you all what they looked like, seemed rather purpose defeating :)

Tuesday, May 12, 2009

Converting Videos to be Nokia N9x Compatible using FFMPEG

This is being posted here so I have something easy to look up when I need to do it over again, but using FFMPEG 0.5.x, you can easily convert any playable movie to a Nokia N9x (N95, N96) compatible MP4 format file with the line:



(ffmpeg | ffmpeg.exe) -y -i [input file].[extension] -f mp4 -vcodec libx264 -level 21 -s 320x240 -b 768k -bt 768k -bufsize 2M -maxrate 2M -g 250 -trellis 1 -refs 3 -keyint_min 25 -acodec libfaac -b 128k [output filename].mp4



Which converts any playable video to a compatible (-level 21), correctly sized (-s 320x240) MP4 based video file with AAC audio (-acodec libfaac -b 128k) that doesn't crash the RealPlayer version on phones in Australia/New Zealand because the buffers and bitrate are cool (-b 768k -bt 768k -bufsize 2M -maxrate 2M).

The other options are entirely optional, but the -g 250 & -keyint_min 25 are recommended if you have a PAL based input stream and would like to be able to fast forward and rewind your video using the funkey buttons on the N96.

Thursday, May 7, 2009

Automatic Vista Speedup with a D-Link DIR-625

note: This article is intended for a technical audience -- you should use caution when modifying a production system -- caveat emptor.

This probably works with the other DIR-6xx models that D-Link sells too, but recently oldfeeb had an issue where his girlfriend's computer (Vista Home Premium) stopped talking wirelessly to the new DIR-625 he'd bought.

He uses Ubuntu, so he saw no difference, but the symptoms on Vista were related to Windows Mail and Internet Explorer refusing to browse, or overly long timeouts.

First up, update Vista for all the recent fixes and reboot -- no luck.

Noticing the cordless phone handset on the wall, I thought: change the wifi channel on the router to something that doesn't conflict with things like cordless 2.4Ghz phones, move channel 5 to channel 11, check.

Reboot Vista, slightly better signal, but the network is still slow -- Google works now, but only after 30 odd seconds, but her mail times out and heavier webpages die a quiet death.

So, using a tip that I found courtesy of Australian Personal Computer magazine some years ago and a bit of Googling, we switched off Vista's 'Autotuning of TCP parameters'.

To do this, you'll first need to open a command prompt as the Administrative User -- which involves:


  1. Go to Start / Run

  2. Type "cmd.exe" into the box provided.

  3. Hold down the Control and Shift keys together -- then -- press [ENTER].


Now, type the following at the prompt:


netsh interface tcp set global autotuning=disabled


Restarted IE7, fired up Google, works flawlessly.

"OK, I thought -- put the Wireless Channel on the router back to 5 (the default)."

We did, rebooted Vista -- Stone, Cold, Silence.

Switched it back to 11, rebooted Vista -- everything's peachy again.

So, sometimes it's not just Vista's fault -- I guess if you're going to buy a Wireless router, you should check what channel ranges are valid for the country you're trying to use the hardware in, before blaming the workstations directly.

Friday, May 1, 2009

Youtube Costs Google.

Stumbled across this article by David Silversmith this morning, which makes interesting reading in the year of the economic downturn.

I looked at the list of leaks that David lists -- and wondered twofold:

How many of those 375 vistors actually look at the content? -- You see sites like Facebook and LiveJournal have the ability to embed Youtube content, so people find a video they like, embed it and every subsequent pageview sends a request to YT to begin streaming the content (in order to show the thumbnail image).

Now, Facebook has the News Feed, as well as the Highlights, as well as Sponsored Clips -- more than once a day, these contain (for me, anyway -- with 100 or so friends) at least one YT link, 99% of which, i'll never actually play, but every one of them actually generate an HTTP request anyway.

Is Youtube simply Google's Loss Leader? -- Google does many other things which are less bandwidth and resource intensive than Youtube, such as Blogger, GMail, Google Scholar, Google Checkout and to a lesser extent, Google Earth to name a few, all of which have the same advertising strategy (Adwords) that Youtube has, at similar pricing scales, it strikes me that Google may take a bath on Youtube in order to draw people in to making a Google Account, thereby gaining access to their other resources and presenting Google with many, many more advertising opportunities they would not otherwise have had.

A thought along similar lines, was "Would Youtube have been this popular if Google hadn't acquired it? -- Reading David's piece further, he talks about Content Acquisition costing money, which is true -- but i'd suggest an ever growing amount of content that Google sends to viewers will be commercial over the course of the next 12-24 months, as the economic downturn bites over and over and causes people to cancel luxury items like subscription television, possibly turning to Youtube to pick up highlights of events as they happen instead.

Google has also done a lot for Youtube that i doubt they could have done on their own -- everything from striking deals for the content, to providing the bandwidth and storage space to sustain the "1 second attention span" internet generation, to adding features like the "High Definition" button to the site itself.

"With Popularity Comes Expense" is a phrase I came up with nearly 15 years ago to define the ability of the "modern" internet to actually exist -- at the time I was working in the pioneering phase of Internet Advertising, back before web based video and when only the technically elite and businesses with vast IT budgets had pages at all.

Nice to see it still rings true today.

How does Google stop the bleeding?

My guess is, it doesn't have to.

Tuesday, April 14, 2009

Installing VMWare Tools on Ubuntu Guest Servers

After hunting around on the web for a while, I couldn't find anyone who answered this in a way that people could run step-by-step, so I hope this helps other people in the future.

I used Ubuntu 8.04.2 LTS for the purposes of this example, but a similar, if not identical set of commands should work for any version of Ubuntu Server.

First, you'll need to have installed VMWare on Windows or a UNIX server and have your Ubuntu Guest running, then you can go to "VM / Install VMWare Tools".

Your first problem, because you're not running a desktop system in your guest -- the CDROM is not automounted for you, so you'll need to do:

mount /media/cdrom

Next, you'll need to copy the .tar.gz file to a place on the installation that has write access, like /tmp:

cp /media/cdrom/VMwareTools-*.tar.gz /tmp/

Next, extract the file:

tar zvxf VMwareTools-*.tar.gz

Change to the directory:

cd /tmp/vmware-tools-distrib/

Now, before we actually run the installer, Ubuntu Server needs some packages installed so the new kernel modules can be built successfully.

apt-get -f install build-essential linux-headers-server linux-server

Once they've been successfully installed, you can run:

sudo perl vmware-install.pl

Most of the defaults are fine, when you are asked for "the location of the C header files for your running kernel" you'll need to answer with the include directory from the kernel you are currently running -- from the looks of things, this trips people up sometimes.

(Ubuntu doesn't ship with a /usr/src/linux directory, so if you press [ENTER] here, you'll get a "Directory not found" message and asked to re-enter the location)

As of the time of writing, the kernel is 2.6.24-23-server, so your location would be:

/usr/src/linux-headers-2.6.24-23-server/include

Once you've done that, the configuration routine will continue through to the end normally and you can reboot your guest OS in order for the changes to take effect.

Saturday, April 11, 2009

"all zones must be in views", BIND 9 and You.

note: This article is intended for a technical audience -- you should use caution when modifying a production system -- caveat emptor.

An interesting question raised by a client, who was experiencing this error in their daemon.log file and asked me to track it down.

A bit of background:

The client in question runs a "Split Zone" configuration, where a seperate set of DNS entries are published to public users (that are only queried by and cannot be altered in any way by external entities) than are published to their other master or slave servers (which are secured by DNSSEC and various other access controls and can be queried by internal LAN users.)

So:



Apr 10 05:41:17 vampire named[8933]: loading configuration from '/etc/bind/named.conf'
Apr 10 05:41:18 vampire named[8933]: /etc/bind/named.conf:12: when using 'view' statements, all zones must be in views



has been in their logs for about six weeks since the server was commissioned and the new administrator wonders if that's the reason their zone information appears out of date?

Well, no.

First off, that message is not actually an error, it's a warning -- but it's still unsightly.

Second, the file it is complaining about is not /etc/bind/zonefiles/m/[name_of_zone].zone but /etc/bind/named.conf which happens to be the default configuration file for most common Linux distributions.

In fact, if you look at the Debian / Ubuntu configuration file you'll see:

"If you are just adding zones, please do that in /etc/bind/named.conf.local"

Which, in this case -- we did, using internal and external views that look a bit like:




view "internal-in" in {
// This view includes our trusted machines, we perform
// recursion in this view and can cache requests for
// our client machines
match-clients { trusted; xfer; };
notify yes;
recursion yes;
additional-from-auth yes;
additional-from-cache yes;

zone "." in {
// Link in the root server hint file.
type hint;
file "/etc/bind/db.root";
};

zone "ministry-of-the-interior.local" in {
type master;
file "/etc/bind/zonefiles/m/forward.zone";
allow-query { any; };
allow-transfer { any; };
};

zone "33.168.192.in-addr.arpa" in {
type master;
file "/etc/bind/zonefiles/m/reverse.zone";
allow-query { any; };
allow-transfer { any; };
};
};




and:




view "external-in" in {
// This view includes our trusted machines, we perform
// recursion in this view and can cache requests for
// our client machines
match-clients { any; };
notify yes;
recursion no;
additional-from-auth no;
additional-from-cache no;

zone "." in {
// Link in the root server hint file.
type hint;
file "/etc/bind/db.root";
};

zone "ministry-of-the-interior.local" in {
type master;
file "/etc/bind/zonefiles/m/forward.zone";
allow-query { any; };
allow-transfer { none; };
};

zone "33.168.192.in-addr.arpa" in {
type master;
file "/etc/bind/zonefiles/m/reverse.zone";
allow-query { any; };
allow-transfer { none; };
};
};




As you can see, we defined the root server hint file for both views, BIND 9.x gets rather tetchy if you don't do that, but will happily continue as long as you do (and, of course -- all your zones verify correctly with named-checkzone)

What, of course -- we failed to do was to define localhost, 127.in-addr.arpa, 0.in-addr.arpa and 255.in-addr.arpa for the internal and external view too.

The error goes away, as expected if you:

Firstly, Comment out the lines for the required zones in the /etc/bind/named.conf file. (Use '//' for commenting in this file)

Then, ammend your zone configuration to look similar to:




view "internal-in" in {
// This view includes our trusted machines, we perform
// recursion in this view and can cache requests for
// our client machines
match-clients { trusted; xfer; };
notify yes;
recursion yes;
additional-from-auth yes;
additional-from-cache yes;

zone "." in {
// Link in the root server hint file.
type hint;
file "/etc/bind/db.root";
};

zone "localhost" {
type master;
file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};

zone "ministry-of-the-interior.local" in {
type master;
file "/etc/bind/zonefiles/m/forward.zone";
allow-query { any; };
allow-transfer { any; };
};

zone "33.168.192.in-addr.arpa" in {
type master;
file "/etc/bind/zonefiles/m/reverse.zone";
allow-query { any; };
allow-transfer { any; };
};
};




and:




view "external-in" in {
// This view includes our trusted machines, we perform
// recursion in this view and can cache requests for
// our client machines
match-clients { any; };
notify yes;
recursion no;
additional-from-auth no;
additional-from-cache no;

zone "." in {
// Link in the root server hint file.
type hint;
file "/etc/bind/db.root";
};

zone "localhost" {
type master;
file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};

zone "ministry-of-the-interior.local" in {
type master;
file "/etc/bind/zonefiles/m/forward.zone";
allow-query { any; };
allow-transfer { none; };
};

zone "33.168.192.in-addr.arpa" in {
type master;
file "/etc/bind/zonefiles/m/reverse.zone";
allow-query { any; };
allow-transfer { none; };
};
};




Check your new configuration validates by running named-checkconf, then restart BIND the warning should vanish and your administrators should all go away satisfied.

Wednesday, April 1, 2009

Web Design Meets Marketing = Fatality

Viral Marketing at it's best.

I laughed ... and I don't think it was even meant as an April Fools Joke.

Monday, March 30, 2009

Could Not Modify Header Information - A Wordpress Experience.

I've been playing with Wordpress as a CMS project recently and came across an interesting "semi-bug(let)" that took ages to resolve, but was rather simple in the end.

A white screen.

Attempting to login to my admin screen after being logged out after a connection dropout gave me a blank screen, nothing on view-source: and no errors in the Apache logfile.

Googling for the issue, I found several posts advising me to clean out my browser cache, clear cookies and check to see if my wp-config.php file ends with a blank line.

None of those fixed it, so I went hunting further and saw people suggesting that one should remove any plugin code -- having a Wordpress installation with heaps of plugins, removing them one-by-one was annoying at best, but some more searching found this neat plugin to resets Wordpress back to it's installation defaults with one click.

(Obviously, if you care about the contents of your blog, or the settings you have crafted for the individual plugins, this isn't for you -- but it helped me out immensely. Kudos to Matt for inventing it.)

Nope -- didn't fix it either.

Removed my theme, restored the default Kubrick theme ...

*shazam*

Fixed.

Put my theme back, logged out, logged back in:

A White Page.

OK, at least I have something to go on, it's a problem with the theme. So I started to poke around further.

It turns out, the functions.php file cannot have spaces in between the functions you define, compare the following code:



<?php
if ( function_exists('register_sidebars') )
register_sidebars(2, array(
'before_widget' => '<li class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));

function widget_search() { ?>
<li class="widget widget_search">
<h2 class="widgettitle">Search</h2>
<input type="text" id="searchfield" />
<img id="searchspinner" src="<?php bloginfo('template_url'); ?>/images/ajax-loader.gif" alt="∗" />
<script type="text/javascript">
var search = new Search('searchfield', 'searchspinner');
</script>
</li>
<?php }
if ( function_exists('register_sidebar_widget') )
register_sidebar_widget(__('Search'), 'widget_search');

?>

<?php

function theme_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;


(code edited)



Fails, but:



<?php
if ( function_exists('register_sidebars') )
register_sidebars(2, array(
'before_widget' => '<li class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));

function widget_search() { ?>
<li class="widget widget_search">
<h2 class="widgettitle">Search</h2>
<input type="text" id="searchfield" />
<img id="searchspinner" src="<?php bloginfo('template_url'); ?>/images/ajax-loader.gif" alt="∗" />
<script type="text/javascript">
var search = new Search('searchfield', 'searchspinner');
</script>
</li>
<?php }
if ( function_exists('register_sidebar_widget') )
register_sidebar_widget(__('Search'), 'widget_search');

?>
<?php

function theme_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;


(code edited)



Works perfectly.

So where was the problem?

the blank line between the closing ?> in the register_sidebar_widget call and the opening <?php in the theme_comments function.

Undoubtably, your error will occur between a different set of functions, but if you are using a functions.php file in your theme and it begins to fail unexplainedly on you, check the file for blank lines between functions as part of your diagnostics plan.

Saturday, March 28, 2009

Microsoft's Support for XP Ending?

Interesting read via ZDNet this morning regarding Microsoft beginning the end-of-life cycle for Windows XP (and, to a similar extent Office 2003).

I find it interesting -- still having people to this day asking if I can kindly remove Vista from their new machines and replace it with XP (and to a similar extent, Office 2007 for either 2003 or OpenOffice) that MS appears to have a longer support deadline for XP than either 2000 or Vista, which have a 5 year lifecycle compared with a 6.5 year one for XP.

I wonder if it'll just cause people to a) switch to Linux or b) use a completely unsupported operating system because Windows 7 is too new and 'innovative' for them and Vista is ... well, Vista.

One thing's for sure, it will have a ripple-down effect into finally removing Internet Explorer 6 woes from web developers minds.

Friday, March 6, 2009

Removing Dreamscape's SEO 3.0 Beta from Zen-Cart

note: This article is intended for a technical audience -- you should use extreme caution when modifying a production system, as your data will be nearly impossible to recover if you use this command incorrectly -- caveat emptor.

One of the more painful things to do in Zen-Cart is removing references to broken module code from your database. You can remove all the PHP files you like, but you'll still see references in your Administration pages for the modules.

In a recent request, I had to switch multiple shops from Dreamscape's SEO 3.0.0beta1 to "something better" due to a change by several shared hosting providers to use SUPHP to protect their client accounts.

After choosing Simple SSU (which is, rather a well written module and is well supported by it's author) -- we were left with the problem of the Configuration Menu in Zen-Cart's admin having two SEO references, one to SSU, one to the older code.

For anyone in the same boat, you can use the following SQL to remove the older module's SQL code from your database:

From the Administration Panel, Go to "Tools -> Install SQL Patches" and enter the following code:


SET @configuration_group_id=0;
SELECT (@configuration_group_id:=configuration_group_id) FROM configuration_group WHERE configuration_group_title = 'Seo Urls 3.0.0-beta1' LIMIT 1;
DELETE FROM configuration WHERE configuration_group_id = @configuration_group_id AND configuration_group_id != 0;
DELETE FROM configuration_group WHERE configuration_group_id = @configuration_group_id AND configuration_group_id != 0;


note: That's four seperate lines with the ;'s ending each line.

I've also posted this as a solution to the thread on the Zen-Cart forums, you can follow the further discussion there -- if you'd like.

Tuesday, March 3, 2009

Useful 'mysqldump' one-liners.

note: This article is intended for a technical audience -- you should use extreme caution when modifying a production system, as your data will be nearly impossible to recover if you use this command incorrectly -- caveat emptor.

I always seem to use these when doing remote administration from the command line -- but when I forget if I should be using -add-drop-table or -add-drop-databases, the usual suspects from Google render terribly on my mobile phone -- so I thought i'd put them here, for later.

To backup a single database:

mysqldump -u [username] -p [database_name] --add-drop-database --lock-all-tables > backupfile.sql

To backup multiple databases:

mysqldump -u [username] -p --all-databases --add-drop-database --lock-all-tables > backupfile.sql

To restore your backup:

mysql -u [username] -p < backupfile.sql

Saturday, February 21, 2009

Lightboxes, Zen-Cart, Oh My!

Recently, a customer asked if they could have image effects on their e-commerce store graphics -- having played around with Wordpress for a while, I knew about Lightbox, which uses either jQuery, Prototype or MooTools in order to show images in a seperate raised window with fancy effects (watermarking, shadowing, etc) while transparently showing the original page in the background.

What I didn't know -- was exactly how many variations of the Lightbox there are.

This site has to be one of the best for deciding which one suits your needs and application best, a must bookmark for anyone interested in knowing the compatibility and abilities of the interschnitzels new 'buzz app'

Sunday, February 8, 2009

Creating Transparent .GIFs from .PNG's

Easy one-liner using "convert" from the Imagemagick graphics suite to get decent .gif conversions of most* transparent .png's.

convert [imagename].png -channel Alpha -threshold 80% [imagename].gif

This converts the Alpha channel (the one IE6 has the most problem with) to either completely transparent or opaque based on the 80% threshold.

I say most, because it doesn't work for things like backgrounds or overlays (which are often too dark -- greys are often black, for example.) -- you can change 80% to 60% if you have backgrounds of mostly one colour, but it's not foolproof and often leaves darker marks around the exterior of the image.

Sunday, January 4, 2009

Ubuntu, Pulseaudio, Small Addendum.

I've tended to use this howto to tweak audio configurations whenever I install a new Ubuntu box for someone -- it makes everything from laptop speakers to Skype work much better, shockwave flash videos work (Youtube, etc) and it makes audio a much better experience all-round.

Today, a user who was having audio stuttering issues in Skype mentioned that when running it in verbose mode (with -vv), the following error occurred:


I: main.c: Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:
I: main.c: We are not in group 'pulse-rt' and PolicyKit refuse to grant us priviliges. Dropping SUID again.
I: main.c: For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of 'pulse-rt', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user.
I: main.c: Note that real-time/high-priority scheduling is NOT normally required. If you experience crackling or other sound anomalies, consider one or more of the above solutions.


The easiest way to fix that, is to open a terminal window and run:


sudo usermod -G pulse-rt -a [username] (where of course, [username] is your desktop username.


(note: it needs to be a capital -G and a little -a to add your user to the pulse-rt group and leave your existing groups untouched, one of those check twice, then check again, then press enter moments)

If you re-run Pulseaudio now, you'll get:


I: main.c: PolicyKit refuses acquire-high-priority privilige.
I: main.c: We're in the group 'pulse-rt', allowing real-time and high-priority scheduling.
I: core-util.c: Successfully gained nice level -11.


Which tends to make Skype and WINE (the two applications the user in question was having stuttering audio issues with) behave more normally.