Thursday, November 14, 2013

Moving Web GUI from one machine to another

Having spent a merry 6 hours installing OMNIbus WebGUI on a VM, I decided it would be better off on a physical machine. This is of course a very silly thing to think, and it was bound to go wrong. Furthermore it is completely unsupported behaviour and I would not suggest following this for any kind of production scenario. For one thing it would completely confuse any installer setup you have, so would not allow the installation of anything else on top of the migrated machine.

Once tarred and copied (basically everything from the install directory downwards) I did a quick grep through to look for configurations that might need to change. It boiled down to 3 files (four if you copied the objectserver over as well):

  1. ./tipv2/properties/objectserver.properties
  2. ./netcool/omnibus_webgui/etc/datasources/ncwDataSourceDefinitions.xml
  3. ./tipv2/profiles/TIPProfile/config/cells/TIPCell/wim/config/wimconfig.xml
Just open those, and do a search/replace for the old/new IP address. If you've copied over the object server as well, you'll need to update the omni.dat file, then re-run nco_igen

Thursday, May 16, 2013

Enabling local network traffic on Ubuntu

My local network consists of an NSLU2 (Slug), a printer and my router. I have made the considered conclusion that it is not going to cause much of an attack vector. My work enforced iptables disagrees, but fiddling with iptables scares me. Luckily I have found ufw, which makes life just *so* much easier: sudo apt-get install ufw sudo ufw enable sudo ufw default deny sudo ufw allow 192.168.1.0/24 Hey presto, I can see my local network. Life is good.

Wednesday, December 5, 2012

SSH Slow to connect on VMs

Been having all sorts of problems with this one. I found a few sites which suggested changing /etc/ssh/sshd_config on the VM to be: UseDNS no That didn't work Then I tried adding my ip address to /etc/hosts. That didn't work. I found that dropping my firewall *did* work, but not too keen on that. Perhaps it was just not allowing ports in/out on that subnet? My knowledge of iptables config is such that I didn't even bother trying. I finally found a helpful hint on http://linux.chrissweeney.co.uk/topic.php?t=21 to use ssh -v name@host This showed me that it was failing to use GSSAuthentication (or something). Chris's blog also helpfully suggested turning that off: GSSAPIAuthentication no Hey presto, lovely quick connection.

Thursday, April 26, 2012

W520 Thinkpad on Natty

I'm about to embark on an upgrade to Precise Pangolin. In light of that, here are a few tweaks I had to make in Natty which I may need to re-do in Precise (or maybe not?)

Sound not working on docking station

Add the following line in /etc/modprobe.d/alsa-base.conf:
options snd-hda-intel index=0 model=thinkpad

Odd settings for nvidia card

I never really conquered this one, but the installation of disper helps by making it possible to dynamically change the monitor. Add
http://ppa.launchpad.net/disper-dev/ppa/ubuntu natty main
to repos then install disper

Making 64 bit Win7 VM work nicely in 32 bit Linux

Add a newer version of Virtualbox (4.1.6 I think) to the repos:
https://ppa.launchpad.net/debfx/virtualbox/ubuntu natty main

Friday, January 27, 2012

In Which I Stop IE 8 Caching Images

I'm not a fan of IE, I'll say that now. Things like the lack of Javascript error feedback (which may have changed with IE9) and the inability to view generated source (again, may have changed) really annoy me. I can code HTML standard pages with Javascript & CSS which work in all other browsers with no 'special' things needed, but they suddenly require a raft of hacks for IE. One thing I have just come across is image caching. I have a page which displays a list of images. I can then bring up an iframed image uploader which resizes images and then refreshes the image display. This works everywhere. Except in IE, where it just shows the original (unchanged) image. 'Aha' I thought - caching, I know, I'll add the good ol' cache prevention stuff, like
This blog posting and even using the meta tags as described in Microsoft's own knowledge base. No joy, same ol' images appearing. It looks like IE doesn't regard images as the property of caches, and stores them in it's own image cache which completely ignores any of those silly 'Do not bloody cache' indicators.

The only way to prevent the caching appears to be to rename your image each time, which is a right royal pain in the codebase, so what's a boy to do? That question mark just there appears to be the answer. I knew that things like Dojo add cache prevention in Ajax by adding a timestamp. Just as an experiment I added a timestampt to an img src attribute (my images are dynamically created by either JS or PHP). Hey presto, it works!

In Javascript I just did:
var imgName = "foo/bar.png";
var time = new Date().getTime();
img.setAttribute("src",imgName+"?"+time);

Whereas in php I just did:
<?php
echo "<img src=\"foo/bar.png?\"".time()."\"/>";
?>
It seems to work in everything I've tried, and has made me quite a happy bunny

Friday, July 29, 2011

Script to update music index in Sonos from Linux

I'm very happy with my little Sonos setup - it's sufficiently hackable because it's all upnp based, and although the supported desktop controllers are only on Windows and Mac, I can do most things I want through the Android controller app.  One thing I could not do, until now, was manually update the music index.  As I'm going through all my CD's re-ripping them at a higher bitrate and putting in higher quality covers this is a bit of a pain.  I have the music index scheduled for 2am each morning, but would still like to be able to add in a new album and update it straight away, without resorting to WINE (not allowed on the work computer, and I'm not terribly fond of using it anyway - it seems like 'cheating'!).  A couple of minutes with wireshark (again, not on my work computer!) allowed me to see the wonderous SOAP call which does the trick.  I cobbled together the following script, and hey presto! it works. Don't forget to change the IP address to be one of your zones. You'll also need curl installed:

#!/bin/sh
curl -H 'SOAPACTION: "urn:schemas-upnp-org:service:ContentDirectory:1#RefreshShareIndex"' -X POST -H 'Content-type: text/xml' -d @updateIndex.txt 192.168.1.73:1400/MediaServer/ContentDirectory/Control
updateIndex.txt:
<s:envelope s:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:body><u:refreshshareindex xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1"><albumartistdisplayoption></albumartistdisplayoption></u:refreshshareindex></s:body></s:envelope>

Monday, May 16, 2011

Making AJAX sites easily visible to search engines

I created a web site a short time ago: Wiltshire Architect Alex Somers. I had quite a bit of fun making the elements fade into each other rather than having an abrupt move from one page to the next. All was well, then I looked at Google's cache of the site. Oh dear, a pretty sparse page with no content. I had made a bit of a schoolboy error in forgetting that Google et al still crawl good ol' HTML, they don't tend (as a rule) to do Javascript. I needed some way of making the site degrade nicely. This works well for two situations. Apart from search engines, some luddites still believe that javascript is satan's code and turn it off. Whilst they're fools, I still want them to employ my client. So what to do? Well, to make my pages sloop into each other I had used anchors rather than pages in my hrefs. This meant that links looked like this:
<a href="#page=architectural_services&category=24">Survey</a>
My javascript then took the page and category variables and then expanded the appropriate menu entry, and put the appropriate content in the page.

I then converted all my links to look like this:
<a href="./architectural_services.php?category=24">Survey</a>
I then made a little javascript function (using dojo):

dojo.addOnLoad(reHash);

function reHash() {
dojo.forEach(dojo.query("a"), function(node) {
    var href = node.getAttribute("href");
    if ( dojo.isIE ) {
      href = href.replace("http://www.alexsomers.co.uk","");
      href = href.replace(/\//,"#page=");
      href = href.replace("#page=#page=","#page=");
    } else {
      href = href.replace(/\.\//,"#page=");
    }
    href = href.replace(/\?/,"&");
    href = href.replace(/\.php/,"");
    node.setAttribute("href",href);
  });
}

Of course, I then had to make some php pages which reflected what would have been done by javascript. It's been a valuable lesson, though. I'll look at ways of creating 'dual' content in my next post.