Home

Travel blog!

  • Oct. 17th, 2009 at 1:45 AM

I am in China - read all about my trip here: www.kamr.no

Norwegian only ...

Tags:

Posting Flickr images to Web Boards

  • May. 10th, 2009 at 4:45 PM

I post images from Flickr on misc Web Boards regularly, and today I wrote a small Perl script to help me along:

The script is available here: kvisberg.net/scripts/flickr2bbc.pl


#!/usr/bin/perl -w
#
#  This script was developed by Ole Bendik Kvisberg (olekvi at kvisberg.net),
#
#  This script is free software; you can redistribute it and/or modify it
#  under the same terms as Perl itself.


use strict;

use Getopt::Long;
use File::Basename;

my $help        = 0;
my $flickrname  = 'olekvi';

# From Flickr.com:
# Flickr Community Guidelines specify that if you post a Flickr photo on
# an external website, the photo must link back to its photo page

my $nolink      = 0;

GetOptions ("flickrname=s"      => \$flickrname,        
            "nolink"            => \$nolink,
            "help"              => \$help);

my $url = shift;
           
if ($help or !$url) {
        usage();
}

createbbc($url);

sub usage {
        printf ("Usage: %s [OPTION] [PHOTOURL]\n", basename($0));
        print "Creates BBCode to insert Flickr photo on web forums\n\n";
        print "  -f  --flickrname   your flickr username (i.e 'olekvi')\n";
        print "  -n, --nolink       skip link (Flickr says you shouldn't!)\n";
        print "  -h, --help         display this help and exit\n";
        exit;
}

sub createbbc {
        my $photourl = shift;
        unless ($photourl =~ m!^http://farm\d+\.static\.flickr\.com/\d+/(\d+)_\w+.jpg$!) {
                printf ("Invalid Flickr photo url:\n%s\n", $photourl);
                exit;
        }
        my $linkurl     = sprintf("http://www.flickr.com/photos/%s/%s/", $flickrname, $1);
        my $photobbc    = sprintf("[IMG]%s[/IMG]", $photourl);
       
        if ($nolink) {
                printf ("%s\n", $photobbc);
        }
        else {
                printf ("[URL=%s]%s[/URL]\n", $linkurl, $photobbc);      
        }
}

Tags:

Flickr Pro

  • Nov. 4th, 2008 at 10:45 PM

I bailed out and paid for a pro account on Flickr.

Goodbye Mr Old Gallery, Hello New Flickr --> http://flickr.com/photos/olekvi/

Perl saves the day

  • Oct. 14th, 2008 at 10:46 PM

After a lot of totally meaningless mouse clicking I have finally automated yet another "web only" task using Perl, Web::Scraper, WWW::Mechanize and cron.

I just love CPAN! And hate the HTML I've been parsing (//table[2]/tbody/tr/td[3]/table/tbody/tr/td/table/tbody/tr *BRRRRR*)


But why didn't I take the time to wrap up these scripts months ago?!

YAPC TV

  • Aug. 23rd, 2008 at 9:25 PM

http://yapc.tv/ - great for all of us not going to any YAPC this year (great for all others as well, I guess)

Summer time

  • Jun. 11th, 2008 at 11:17 AM

And my first summer in like 15 years I don't have to touch a computer, unless I want to.

I like this new situation a lot, not sure for how long, though.


Done more than 5000 km on the motorcycle already this season - great weather, and enough time results in pure fun!

Phun!

  • Feb. 22nd, 2008 at 7:12 PM



Phun is really cool!

Grab it here and waste the rest of your day :-)

Tags:


Some days ago I wrote about how I HATED hardware.

I still do, and after failing with the SiL S-ATA controllers I bought a new four channel controller from Promise, the TX4 300 arrived on saturday.
A shutdown, some yelling and messing around with screws, pci cards and those damn crappy S-ata cables later the box was up and running again.

Impressed, but not surprised, I watched ZFS assembling the raid as if nothing have happened since last boot, though three of five disks in the raid had changed device name.  ZFS 1 - Hardware 0

I was told to run zpool scrub raid and after a few hours I could see a lot of zfs checksum errors, those awful DMA errors in syslog was gone though.  A new file system scrub found even more checksum errors, and I got a bit worried.  Perhaps there is memory problem?

A reboot-with-new-ram-and-two-scrubs later I got zero checksum errors and zero DMA errors in my syslog.  *whee!*
... the system has been running with a high IO load for 72 hours now, and still no errors  *double whee!*

The good thing: ZFS has never created errors which it wasn't able to fix; all my files are ok, and I've learned quite a lot about ZFS on my way:  ZFS 2 - Hardware 0
The bad thing: I've spent way to much time debugging hardware (and money on new hardware).

Note:

Using the fantastic LXR I found the following in the Linux driver for SiL:

MODULE_PARM_DESC(slow_down, "Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)");

Perhaps that is why my buggy SiL hardware have worked for years on my Linux system?


Tags:


I own a old, but still very usable IBM ThinkPad T30. You know, that kind of a laptop which probably will live forever as long as you give it a new battery every third year ...

The Thinkpad was bought in the US, and has got a US keyboard layout, which is nice for everything but writing characters like æ, ø, å, Æ, Ø, Å,.

My T30 is running Ubuntu 7.10, but this should work for all systems running some kind of X and support xmodmap, and the idea is simply to remove the normal caps lock behaviour, which is never used anyway, and then use the combination of caps lock and another key to produce my beloved "Norwegian characters".

This is very easy using xmodmap, and my .Xmodmap looks like:
!
! This is an .Xmodmap file for my IBM T30 with an american keyboard layout
! supporting æøå, ÆØÅ using Caps Lock
!
! Ole Bendik Kvisberg
!

clear lock
keycode 66 = Mode_switch

! norwegian chars
keycode 34 = bracketleft braceleft aring Aring
keycode 47 = semicolon colon oslash Ooblique
keycode 48 = apostrophe quotedbl ae AE


! broken in default config
keycode 21 = equal plus
keycode 35 = bracketright braceright

I HATE hardware!

  • Jan. 31st, 2008 at 3:59 PM

... at least the buggy ones.

At home I got a two or three years old P4 computer, mainly used as a file server, hidden in a closet.  Very nice when everything works, not nice at all with buggy hardware in it.

Normally I use Linux on all my computers, preferable Ubuntu, but I really wanted to play around with ZFS on the file server so I installed FreeBSD 7.0 RC1 on it some days ago.  The install went very well, and I was quickly able to create a raidz of 5 Samsung S-ATA drives.

Three of the drives are connected to the onboard S-ATA controller on my main board, and the two last disks are connected to two separate 'Sil 3512 SATALink/SATARaid Controller' PCI controllers.  Wanna guess which disks are on the SiL?

        NAME        STATE     READ WRITE CKSUM
        raid        ONLINE       0     0     0
          raidz1    ONLINE       0     0     0
            ad15    ONLINE       0     0     0
            ad13    ONLINE       0     0     0
            ad4     ONLINE       0    34    11
            ad8     ONLINE       0    42     9
            ad14    ONLINE       0     0     0

No rewards for guessing ad4 and ad8, sorry.

My syslog is filled with messages like:

Jan 31 15:44:05 dj kernel: ad4: TIMEOUT - WRITE_DMA48 retrying (1 retry left) LBA=473275789
Jan 31 15:44:10 dj kernel: ad4: TIMEOUT - WRITE_DMA48 retrying (0 retries left) LBA=473275789
Jan 31 15:44:15 dj kernel: ad4: FAILURE - WRITE_DMA48 timed out LBA=473275789
Jan 31 15:44:15 dj root: ZFS: vdev I/O failure, zpool=raid path=/dev/ad4 offset=242317203968 size=32768 error=5
Jan 31 15:45:31 dj kernel: ad8: TIMEOUT - WRITE_DMA48 retrying (1 retry left) LBA=
Jan 31 15:45:31 dj kernel: ad8: FAILURE - WRITE_DMA48 status=51<READY,DSC,ERROR> error=10<NID_NOT_FOUND> LBA=488396070
Jan 31 15:45:31 dj root: ZFS: vdev I/O failure, zpool=raid path=/dev/ad8 offset=250058787840 size=1024 error=5
Jan 31 16:03:14 dj root: ZFS: checksum mismatch, zpool=raid path=/dev/ad4 offset=208201856000 size=32768
Jan 31 16:05:41 dj root: ZFS: checksum mismatch, zpool=raid path=/dev/ad4 offset=152869227520 size=32768


I've tried to Google error messages, and I'm not the only one having trouble with the SiL shit, but I still haven't found any solution to my problem, except for the obvious 'buy a new S-ATA controller, and a working one this time!' approach.

Comments and help on this one is warm welcome :-)

Using OpenWRT as a IPv6 router

  • Jan. 29th, 2008 at 7:44 PM

Two days ago I wrote about how I installed the Kamikaze release of the fabulous OpenWRT router software, today I did some research and IPv6 enabled the router (and my home network).

First I installed some software on the router.

IPv6 support for the Linux kernel:

ipkg install kmod-ipv6
IP, used to manipulate IPv6 addresses and routes:

ipkg install ip
And what is needed for a IPv6 firewall:

ipkg install kmod-ip6tables
ipkg install ip6tables

I'm so lucky I got a /60 net routed towards my home over a 6to4 tunnel provided by a local IPv6 fanatic here in Norway, if you are not so lucky you may take a look at some of the public tunnel brokers.

With the tunnel set up on the upstream side I (re)wrote a init script (/etc/init.d/tun6to4) for 6to4 on the Kamikaze OpenWRT:

#!/bin/sh /etc/rc.common
# 6to4 tunnel
START=50

# Modified version of script from http://wiki.openwrt.org/IPv6_howto

# retrieve the public IPv4 address
ipv4=$(ip -4 addr | awk '/^[0-9]+[:] eth0.1[:]/ {l=NR+1} /inet (([0-9]{1,3}\.){3}[0-9]{1,3})\// {if (NR == l) split($2,a,"/")} END {prin
t a[1]}')


# local part of linknet for relay tunnel
linkipv6prefix=<local IPv6 address on the link net - provided by tunnel broker>

# IPv4 address for our relay
relay6to4=<IPv4 address for tunnel termination - provided by tunnel broker>

# local net, configured in radvd.conf
localipv6prefix=<local (lan) IPv6 net - routed by tunnel broker; not needed to get IPv6 up on router>

start() {
    echo "Creating tunnel interface..."
    ip tunnel add tun6to4 mode sit ttl 64 remote any local $ipv4
    echo "Setting tunnel interface up..."
    ip link set dev tun6to4 up
    echo "Assigning ${linkipv6prefix} address to tunnel interface..."
    ip -6 addr add ${linkipv6prefix} dev tun6to4
    echo "Assigning ${localipv6prefix} address to br-lan..."
    ip -6 addr add ${localipv6prefix} dev br-lan
    echo "Adding route to IPv6 internet on tunnel interface via relay..."
    ip -6 route add 2000::/3 via ::${relay6to4} dev tun6to4 metric 1
    echo "Adding route to IPv6 localnet..."
    ip -6 route add ${localipv6prefix} dev br-lan
    echo "Done."
}

stop() {
    echo "Removing br-lan interface IPv6 address..."
    ip -6 addr del ${localipv6prefix} dev br-lan
    echo "Removing routes to 6to4 tunnel interface..."
    ip -6 route flush dev tun6to4
    echo "Setting tunnel interface down..."
    ip link set dev tun6to4 down
    echo "Removing tunnel interface..."
    ip tunnel del tun6to4
    echo "Removing routes to IPv6 localnet..."
    ip -6 route flush dev br-lan
    echo "Done."
}

restart() {
    echo "Stopping..."
    /etc/init.d/tun6to4 stop
    echo "Starting..."
    /etc/init.d/tun6to4 start
    echo "Done."
}
After some testing I ran:

/etc/init.d/tun6to4 enable
reboot

The reboot went very well and with the router back on line I could ping a IPv6 enabled host on the Internet; yummy!:

root@OpenWrt:~# ping6 -c 1 ldap.uninett.no
PING ldap.uninett.no (2001:700:0:513::10): 56 data bytes
64 bytes from 2001:700:0:513::10: icmp6_seq=0 ttl=56 time=271.1 ms

--- ldap.uninett.no ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 271.1/271.1/271.1 ms
But it is not very useful with a IPv6 enabled router unless the computers on the inside may use IPv6 as well!  I therefore installed  The Linux IPv6 Router Advertisement Daemon on my router:

ipkg install radvd
and configured it in /etc/radvd.conf:

interface br-lan
{
        AdvSendAdvert on;
        prefix <local (lan) IPv6 net - as set up in tun6to4 init script and routed to you by tunnel broker>
        {
                AdvOnLink on;
                AdvAutonomous on;
        };
};

All ready to fire it up:

/etc/init.d/radvd enable
/etc/init.d/radvd start

My laptop got a auto configured IPv6 after a few seconds:

wlan0     Link encap:Ethernet  HWaddr 00:13:E8:9E:CC:F7 
          inet addr:192.168.192.50  Bcast:192.168.192.255  Mask:255.255.255.0
          inet6 addr: XXX:YYY:ZZ:e8ff:fe9e:ccf7/64 Scope:Global
          inet6 addr: fe80::213:e8ff:fe9e:ccf7/64 Scope:Link
          [..]

And everything worked;  I could connect to a IPv6 enabled computer on the Internet from my laptop, but hey; I could also connect to my server at home from the Internet - nice, but some descent IPv6 firewall on the OpenWRT router is really needed :-)

See http://wiki.openwrt.org/IPv6_howto for more information about OpenWRT and IPv6.

NOTE: Please do not contact me if you turn your brand new wlan router into a fancy looking brick!

I have been running OpenWRT White Russian release on my Internet Gateway for a few years; now I wanted to try something new and set up a "secure" Wireless AP.

For a start I downloaded the Kamikaze release with a 2.4 kernel of OpenWRT from http://downloads.openwrt.org/kamikaze/7.09/brcm-2.4/ (openwrt-wrt54g-2.4-squashfs.bin - The Broadcomm wireless is not working with the current 2.6 kernel in 7.09)

My router was running the operating system shipped from Linksys so I just installed using the original Linksys web interface.   Worked just great!

The router performed a reboot and I connected to the router using telnet  (telnet 192.168.1.1) and created a password for the root account:

root@OpenWrt:~# passwd
Changing password for root
New password:
Retype password:
Password for root changed by root


Setting the password semi disables the telnet daemon, the router accepts connections on port 23 (telnet) but hangs up immidately; I wanted to disable the telnet service totaly, and after verifying I was able to login using ssh I ran:

root@OpenWrt:/# /etc/init.d/telnet stop
Terminated
root@OpenWrt:~# /etc/init.d/telnet disable


The default installation installs and runs a httpd server as which I didn't need as well:

root@OpenWrt:/# /etc/init.d/httpd stop
Terminated
root@OpenWrt:~# /etc/init.d/httpd disable


Because the RFC 1918 network 192.168.1.0/24, which the OpenWRT defaults to use as lan network, was already in use in my home network I decided to use 192.168.192.0/24.  To change this I simply fired up vi (busybox version installed by default) and edited /etc/config/network:

[..]
config interface lan
[..]
        option ipaddr   192.168.192.1
[..]


I really like the scratching of nvram storage and introduction of uci in the Kamikaze release; instead of editing /etc/config/network I could have used uci:

root@OpenWrt:~# uci get network.lan.ipaddr
192.168.1.1
root@OpenWrt:~# uci set network.lan.ipaddr=192.168.192.1

root@OpenWrt:~# uci get network.lan.ipaddr
192.168.192.1

root@OpenWrt:~# uci commit network


Great; I still love plain and simple configuration files, though.

The default IP address, 192.168.1.1, seems to be hardcoded in some files in /etc - grep -r '192\.168\.1\.1' /etc* showed me a few files I had to change, /etc/resolv.conf was probably the important one, and has to be hardcoded.

Now, after making sure there was no IP conflicts,  I was ready to plug the new router into my home network.  I will not go into detail on the network layout here, but there is a DHCP server available on the net which I plugged the wan port of the router into.  The default configuration enables DHCP (as a client) on the wan port; nothing to do - my new OpenWRT box was connected to the internet, and I checked if there were any updates available:

root@OpenWrt:/etc# ipkg update
Downloading http://downloads.openwrt.org/kamikaze/7.09/brcm-2.4/packages/Packages
Updated list of available packages in /usr/lib/ipkg/lists/release
Downloading http://downloads.openwrt.org/kamikaze/packages/mipsel/Packages
Updated list of available packages in /usr/lib/ipkg/lists/packages
Done.
root@OpenWrt:/etc# ipkg upgrade
Nothing to be done
Done.

Nothing?!  How boring!

How about some clean up then;  I will never (last famous words) use PPP on my router:

root@OpenWrt:/# ipkg -recursive remove *ppp*
Removing package ppp-mod-pppoe from root...
Removing package kmod-pppoe from root...
Removing package ppp from root...
Removing package kmod-ppp from root...
Done.


Running ipkg list_installed did not show me any more packages to remove but I will add a few packages with ipkg install to support my IPv6 setup, probably more about that later.

First I wanted to get the wireless up and running, after all it is a wlan router I have bought, not a toy (but hey it *is* a toy too!).  And not to forget; with wlan up and running the router could stay in my 'office' and I could do the rest of the configuration from the sofa together with my lazy cat, which prefers wired networking (to play with).

Enabling wireless is as simple as removing one line in /etc/config/wireless:

config wifi-device  wl0
[..]
        # REMOVE THIS LINE TO ENABLE WIFI:
        # option disabled 1
[..]

I changed the ssid and encryption settings as well:

[..]
config wifi-iface
[..]
        option ssid     obk
        option hidden   1
        option encryption psk2
        option key      mysecretkey


And after a network restart (/etc/init.d/network restart)  I was then able to connect to my brand new OpenWRT router from my Thinkpad running Ubuntu 7.10 with WPA2 encryption - probably quite crackable, but a bit safer than wep at least.

NOTE: I tried using 'encryption wpa2' first, which is supported, but should only be used in combination with a radius server.  I might dive into OpenRADIUS some other day, or I may not - there will probably not be a lot of users and a shared key works fine I think ...


You may find some more information about hardware and specially the install procedures here:
http://wiki.openwrt.org/OpenWrtDocs/Hardware/Linksys/WRT54GL

OpenWRT really rocks; and I already prefer Kamikaze over White Russian.

Profile

[info]olekvi
Ole Bendik Kvisberg

Advertisement

Latest Month

October 2009
S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728293031

Syndicate

RSS Atom
Powered by LiveJournal.com
Designed by Lilia Ahner