Record of some of the computer tech I deal with so that it's documented at least somewhere.

Sunday, 30 September 2007

Bluetooth at bluetongue time

A long term solution to eradicate the spread of bovine diseases is to shoot the dairy farmers.

Anyway, on with the dog & pony.
# apt-get install bluez-utils
This also auto-starts bluetooth so now the devices should see each other :
; hcitool scan
Scanning ...
00:11:22:33:44:55 Maht 00:12:D2:C5:73:56


Oh lucky me, I have a golden MAC
The bugger spends 10s scanning.

You need to advertise the Integral dongle thusly :
# dbus-send --system --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable

(though I added this to /etc/init.d/bluetooth on rod)

sdptool search OPUSH
That's quicker if it's cached or something, the second scan is almost instant but the first longer.

obexpushd looked like the answer but it anonomizes the received files, probably an oversight. Also the first two bytes were corrupt, and the text file was utf/unicode - that was probably some file magic at the start FFFE

Next step is PyBluez I think, see if I get any control.
# apt-get install python-bluez

F1 race now though Japan

; python
import bluetooth
bluetooth.discover_devices(duration=1,lookup_names=True)
<< [('00:11:22:33:44:55', 'Maht')]

I'm pretending the UI is the opposite for cut & paste reasons, copying python in the terminal is soooo annoying

hmm, that's just the base bt protocols, i.e. l2cap & rfcomm
Obex goes over rfcomm by the look of it
so openobex next - cripes thats not fun

next step: hack obexpushd code to see if it will bend to my will

means installing bluez-utils from source
# cd /usr/src
# apt-get source libbluetooth2
# cd bluez-libs-3.7
# ./configure
# make install
# cd .. && apt-get source libopenobex1 # though I could have sworn it was a diff lib
# cd
libopenobex-1.3
# ./configure --enable-apps
# make install
# cd /usr/src/obexpushd-0.4+svn10/src
# make

yay it worked, that means I can hack obexpushd

The loop just returns open fds to read from :(

got to work out how to get the remote address from the fd.

After I watch the F1 highlights - crazy rain smashy no hurt

trying obex_test as a better candidate

Sunday, 23 September 2007

Can your OS do this ? part 1

I've got two Plan 9 servers : eric and plum on 192.168.254.1 and 192.168.9.9
Two Lunix servers : storm (debian etch) and momo (OpenSBD) on 10.0.0.1 and 192.168.9.14

eric is running in qemu on storm, storm is behind n NATs (where n > 1)
storm gets its external ip via DHCP from the first NAT on the subnet 192.168.52.0
storm runs VDE on the 192.168.254.0 subnet, eric sees storm as 192.168.254.254
storm is not internet facing

< here lies the internet >

plum is behind a NAT but is port forwarded, plum's ip is 192.168.9.9
momo is on the same subnet
eric think's plum's IP is the external one

eric import(4)s storm's file system at boot, its path is /n/storm_root
eric union bind(1)s /n/storm_root/home/plan9/bin to /bin, effectively putting that directory in the path

then eric executes srv_eric

which redirects to the file located at /n/storm/bin/srv_eric
which redirects to the file located at /n/storm_root/home/plan9/bin/srv_eric
which is really on the machine storm as /home/plan9/bin/srv_eric

it contains :

#!/bin/rc
rm -f /srv/ericnet # in case it's run again after boot
srvfs ericnet /net # export eric's network
cpu -h plum -c /mnt/term/bin/eric_arrived

the cpu command logs into plum's IP via port forwarding and when it gets a shell it executes /mnt/term/bin/eric_arrived

eric_arrived is also in /home/plan9/bin on storm, cpu takes its namespace with it into /mnt/term

#!/bin/rc
rm -f /srv/ericnet # in case this is a reconnect
mount /mnt/term/srv/ericnet /n/ericnet # mount eric's srv entry for this script to use
srvfs ericnet /n/ericnet # export it again so everyone can see it in /srv
chmod 666 /srv/ericnet # make it available for r/w
read # keep it alive

I log into into plum (with cpu or drawterm or whatever)
in my lib/profile I have

get_eric

which is actually at /n/momo/home/plab9/bin/get_eric and contains :

#!/bin/rc
mount /srv/ericnet /net.alt
srv /net.alt/tcp!storm!9fs /n/storm_root

which mount's eric's network on /net.alt
and then uses that network connection to mount storm's file system on plum

We can use eric's network for all the usual stuff i.e.

plum% ip/ping -n 1 /net.alt/icmp!10.0.0.2
sending 1 64 byte messages 1000 ms apart to /net.alt/icmp!10.0.0.1!1
0: rtt 148045 µs, avg rtt 148045 µs, ttl = 64
plum%

The only problem I have at the moment is that eric doesn't notice when plum goes away, both LANs are unreliable.

I think there might be a better way of doing all this, I'm hoping this blog post will help me reveal it, after all, I only just worked all this out for the first time. I've not had a remote Plan 9 box before. I looked an aan but I can't quite see how to use it for this.

Thursday, 20 September 2007

ppm2eps

I started out with the idea to do the per screening paperwork.
I needed to include the images.
After much run around and a broken gs I finally got ppm2eps out the door

in the usual place
http://plan9.bell-labs.com/sources/contrib/maht/

Which also means jpg2eps png2eps 92eps gif2eps

I'll have a go at including jpegs in dct form some time but for now everything is uncompressed

Friday, 14 September 2007

httpd on the cpu server

After battling getting the mounted stuff working on a terminal I thought all was well once I moved it on to a cpu server, but nope. I got it running without complaint but it says /usr/web is missing when I get any pages. (see /n/sources/contrib/maht/httpd for that logging improvement :)

snacktime brb

yum, beans on toast

on the cpu server it's bootes that kills the processes so I'm glad I'm not across the sea

yay I got it worked out eventually


/cfg/$sysname/cpurc :

srv storm

/cfg/$sysname/cpustart :

. /cfg/$sysname/namespace
@{
rfork
bind /n/storm/httpd/httpd.rewrite /sys/lib/httpd.rewrite
ip/httpd/httpd -w /n/storm/httpd/web -n /cfg/$sysname/namespace.httpd
}

/cfg/$sysname/namespace :

mount /srv/storm /n/storm_root
bind /n/storm_root/home/plan9 /n/storm
bind -a /n/storm/bin /bin

/cfg/$sysname/namespace.httpd :

bind /n/storm/httpd/bin /bin/ip/httpd


that is finally it :)


We really need better http logging if we want to do proper analysis.
I need to investigate the best stats package and then output something that conforms to that.
Or, better still, have it output troff somewhere and issue pdfs as stat reports

ip/httpd/httpd namespace trouble

because ip/httpd/httpd does a newns

you can't do this :

9fs rod
bind -a /n/rod/web/bin /bin/ip/httpd/

and then /magic/ anything from /n/rod/web/bin

any magic files have to be in /bin/ip/httpd
which is owned by sys:sys

lol, then i remembered mount /sys/rod /n/rod && bind /n/rod/web/bin /bin/ip/httpd/
worked a treat

it would be ok if you could do : httpd/httpd < /n/rod/web/namespace

aha, genius strikes, I created /cfg/$sysname/httpd.namespace and used that :>

I would also recommend adding syslog(0, HTTPLOG, "%r: %s", w);
To the if(fd < 0) in the function send so you log what file was missing.
I'm going to add a patch for that later also

see /n/sources/contrib/maht/httpd for that and a bugfix that's in the patch queue.

Tuesday, 4 September 2007

FTP / Anonymous uploads

I presume that anonymous uploads is best achieved with ftp

It's also a fast file transfer medium for Windows - faster than Samba and scp

I'm going to go with Pure-ftpd I've used it before on OpenBSD and it looks ok.

Monday, 3 September 2007

Back to Qemu

When I ran my qemu script I got "connect: no such file or directory"

considering there's no "connect" which is coming from vde

So now I have to remember how to start vde_switch - not that it really worked last time !

http://www.slackware.com/~alien/slackbuilds/vde/build/Using_VDE_with_QEMU_HOWTO.txt

# vde_switch -tap tap0 -daemon
# ifconfig tap0 192.168.254.254

add the necessary routing
# iptables --append FORWARD --in-interface tun0 -j ACCEPT

I can ping into qemu and I can ping 192.168.254.254 but not beyond

bah ifconfig had the wrong ip

all working now

Seam Carving

I found a c source for doing seamcarving
http://inamidst.com/code/seamless.c

The results are like this :

http://blog.eikke.com/index.php/ikke/2007/09/02/seam_carving_content_aware_image_resizin


I had to install zlib (from source)
then libpng12-0 (from source)
then libjpeg62
then libfreetype6
then libgd2-xpm

though the libjpeg didn't work so I ended up with

** Configuration summary for gd 2.0.33:

Support for PNG library: yes
Support for JPEG library: no
Support for Freetype 2.x library: yes
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes

packages.debian.org isn't working properly which is a pain


OK, i got it working but the results are a bit shite

look into it some other time