Archive

Archive for the ‘Uncategorized’ Category

Instalace Magento

June 15th, 2008 admin No comments

Sorry, this entry is only available in Czech.

Tags: ,

Installing webcam drivers for OpenWRT

March 14th, 2008 admin No comments

As I described here, I’ve bought Asus WL-500g Premium router where I installed Kamikaze 7.09 firmware to. I am running on Linux 2.4 kernel, because 2.6 doesn’t support wifi on my router (see here).

I’d like to connect some USB webcam, but even I spent a lot of time trying to find some usable driver, I didn’t suceed so far.

Here are drivers which are not usable for my case:

  • UVC video driver (kmod-video-uvc) supports only >= 2.6 kernels
  • ov51x-jpg also supports only >= 2.6 kernels
  • qc-usb driver for Logitech webcams (download) didn’t work for me

These drivers may work:

  • ov51x driver may work, but I didn’t find binaries for Kamikaze
  • spca5xx (download or as a ipkg package kmod-usb-spca5xx-le) seems to be most perspective for me
  • OpenWrt Kamikaze 7.09 has directly support using ipkg for pwc driver. These cams listed are pretty good and pretty expensive ;-).

Programs supported

Copied from this discussion:

  • spca5xx_le - spcacat, servfox
  • spca5xx - spcacat, servfox, motion, palantir, mvc, getjpeg

Solution

Based on this talk, I decided to buy webcam “Labtec webcam pro”. Instructions based on this great tutorial (in polish, but I guess you don’t mind) are following:

  • Connect the webcam to router. Restart it. You should get in “dmesg” output this:
    usb.c: USB device 2 (vend/prod 0x46d/0x8a2) is not claimed by any active driver.

    That sound great, because this vend/prod is supported by spca5xx

  • Install usb stuff, if not installed:
    ipkg install kmod-usb-core kmod-usb-uhci kmod-usb2
  • Install the spca5xx light edition driver:
    ipkg install http://download.czechit.net/openwrt/kmod-usb-spca5xx-le_2.4.34-brcm-1_mipsel.ipk
  • Everytime after restart of the router, you have to load the modules using:
    insmod videodev
    insmod spca5xx
  • Now, if you check “dmesg”, you should get:
    Linux video capture interface: v1.00
    usb.c: registered new driver spca5xx
    spca_core.c: USB SPCA5XX camera found. Type Labtec Webcam Pro Zc0302 + Hdcs2020
    spca_core.c: spca5xx driver 00.57.08LE registered
  • Search for the device, make link for spcacat and install this software for downloading images from webcam:
    ls -al /dev/v4l/*
    ln -s /dev/v4l/video0 /dev/video0
    cd /tmp
    wget http://download.czechit.net/openwrt/spcacat.gz
    gunzip spcacat.gz
    mv spcacat /usr/bin
    chmod +x /usr/bin/spcacat
    ipkg install libpthread libgcc
  • To make one “shot” to file SpcaPict.jpg use:
    spcacat -d /dev/video0 -g -s 640x480 -f jpg -o -N 1 -p 100

Warning: Based on this post, it’s possible that connecting 2 and more cams won’t be easy.

Links

Tags:

Quick intro into Ubuntu

March 8th, 2008 admin No comments

I decided to move to Ubuntu. Here are quick steps:

  • Install Windows.
  • Download bootable Ubuntu CD. Boot it. Try it. Use partition utility in System menu to create 2 partitions for Ubuntu - one as unused, where will be Ubuntu installed later and second linux-swap type.
  • Follow instructions, make sure you are connected to internet - neccessary to download apt repository index. Reboot.
  • Add secondary keyboard: System - Keyboard - Layouts and then in “Layout Options - Group shift/lock behaviour” choose Alt+Shift to switch keyboard’s layouts
  • Check content of /etc/apt/sources.list - repositories should be uncommented, so installing packages (e.g. plugins to Firefox) may work.
  • Searching for packages is described here. For example: apt-cache search php
Tags:

Port forwarding under OpenWrt

March 3rd, 2008 admin No comments

Honesly, I don’t understand /etc/config/firewall config, coz it’s working pretty strange for port forwarding. I have even found a lot of pages reporting bugs in Kamikaze build during port fw. After several hours, I have found command, which works for Kamikaze - just edit /etc/firewall.user and add:

iptables -t nat -A PREROUTING -p tcp --dport 3535 -j DNAT --to-destination 192.168.1.126:80
iptables        -I FORWARD -p tcp --dport 3535 -d 192.168.1.126 -j ACCEPT
Tags:

mBank API - programové rozhraní v Pythonu pro českou mBank

February 28th, 2008 admin No comments

Tags:

Zkušenosti s mBank

February 11th, 2008 admin No comments

Sorry, this entry is only available in Czech.

Tags:

Forwardování TCP portů přes Putty

January 27th, 2008 admin No comments

Port forwarding using SSH allows you to make virtual TCP port which goes through an SSH connection, even to local networks. There are many tutorials on the net, but they seemed to me complicated…so I wrote this quick tutorial using some example cases. For portforwarding you need a SSH client (for example Putty) and SSH server on the server (for example SSHD running on your router).

There are 2 main port forwarding cases:

  • Local port forwarding
  • Remote port forwarding

Local port forwarding using Putty

When you gonna need this: You have possibility to access some computer in a particular network (it has public IP or port forwarding is enabled on NAT), but you cannot access local computers in that network.

For example: You want to connect from your work to port 80 (webserver) of your home PC with local IP 192.168.1.100. You cannot do this directly, because this IP is hidden in LAN. So you make SSH connection to some device with public IP (e.g. router, server), where SSH server is running and tunnel port from your localhost to 192.168.1.100 port 80.

Local port forwarding - Visio

In the putty on your client computer, you specify hostname of your public IP server.
Local port forwarding - host

And then create a record for port forwarding. Port 5050 on your local machine will be forwarded to port 80 at 192.168.1.100 in your home network. Don’t forget to press “Add” button.
Local port forwarding - tunnel

Now you can connect to your SSH server using button “Open”. After you successfully login, you can point to address localhost at port 5050 which will be forwarded to 192.168.1.100 at port 80. So in this case, when forwarding webserver port, you may put http://localhost:5050 to your web browser.

Remote port forwarding

When you gonna need this: You are in the local network and you can publish any network’s service to the internet, even if your provider doesn’t have any public IP server nor ssh server.

For example: You are at school and you like FTP server at 192.168.1.100 (port 23). You want to connect to this FTP from your dormitory. You cannot use “local port forwarding”, because school doesn’t have SSH server on public IP or you don’t have access to it. Solution is simple: You forward port 23 to your own ssh server anywhere on the internet.

Remote port forwarding - Visio

In the LAN network (where you have access to 192.168.1.100 computer, port 23) you create a SSH connection to hostname of your public accesible SSH server.
Remote port forwarding - host

In the tunnels settings you specify following. Don’t forget to check “Remote” and “Local ports accept connections from other hosts” (DANGEROUS).
Remote port forwarding - tunnel

As soon as you establish SSH connection to your public SSH server, anyone from internet can access port 5050 on your SSH server and connect to local computer 192.168.1.100 which was previously protected by NAT. This is ofcourse dangerous, if you don’t know what are you doing.

These connections work as long as the SSH tunel is opened from LAN (school) network.

Better solution - combine remote and local port forwarding

Because remote port forwarding itself can be pretty dangerous - better solution for this can be combination of both.

Steps:

  • From your school you create SSH connection to your SSH server (exactly as described in “remote port forwarding” part), but you don’t allow “Local ports accept connections from other hosts” - it means that localhost on SSH server can access this port, but noone from outside network.
  • From your dormitory, you create SSH local port forwarding connection to your public SSH server. You forward local port 5051 to 127.0.0.1:5050 (localhost at SSH server).
  • Now you can access 192.168.1.100:23 at your school from your dormitory using localhost:5051. So for example: ftp://localhost:5051

Comments, questions

If any questions, please add comment bellow.

Tags:

Vyhledávání MP3 googlem

January 22nd, 2008 admin No comments

Sorry, this entry is only available in Czech.

Tags:

Instalace Linuxu do Asus WL-500gP

January 12th, 2008 admin 3 comments

Hey guys. Today, I’ve bought a new Asus WL-500g Premium multi functional wireless router. In folowing paragraphs, I’m going to show you, how to uninstall official firmware from Asus and instal open source project OpenWRT based on linux. After that it’s easy to use you router as a rsync, http, ssh, ftp server or as an video surveillance.

Install recipe of OpenWRT to this router is here.

Installing Linux

  • OK, first, I recommend to backup original firmware from your router. Follow the procedure described in section “Backup” here. The script was running about 5 minutes when backuping my router, so stay patient and don’t stop it or power off, otherwise you can destroy your Asus.
  • Download last version of Kamikaze OpenWRT linux clone. Current version for this router is here.
  • Make sure you are connected directly to LAN1 port and you have enabled receiving IP address from DHCP server on your computer’s settings.
  • Install Asus original software from attached CD. Run (but don’t upload fw yet) “Firmware Restoration” tool and enter diag mode on your router using following instructions.
  • Upload a new downloaded TRX file to the router and let it restart by “Firmware Restoration” tool. (takes about 1 minute)
  • Well, we are done. You can connect using telnet 192.168.1.1, without password.

Using USB as a Linux harddrive

There is just 32 MB of storage and RAM (shared) space. So first we need to install USB drivers to be able to install aditional software to the USB instead of internal Asus’es memory. The tutorial is here.

Attention: FAT doesn’t support symbolic links, so programs cannot be installed to FAT easily. We need to reformat FAT into e.g. EXT3. See folowing steps…

  • In the router is “ipkg” package management software. First we update list of resources using:
    ipkg update
  • Now we install drivers for USB (I assume you have USB 2.0 drive):
    ipkg install kmod-usb2ipkg install kmod-usb-storageipkg install kmod-fs-ext3
  • It’s time to reboot the router:
    reboot
  • Now we install tools for formating drive to EXT3 file system:
    ipkg install e2fsprogs
  • Check “dev” directory where is attached USB located:
    dmesg
    fdisk -l
  • Before formating, consider creating partition using fdisk for swap. Format the whole disk to EXT3 fs:
    ipkg install e2fsprogsmke2fs \
       -j /dev/scsi/host0/bus0/target0/lun0/part1

    Tool mke2fs may fail on 300GB and bigger disks. Replace “/dev/scsi/host0/bus0/target0/lun0/part1” with your particular location detected by fdisk -l or dmesg

  • Then we can remove tools for formating, if we know we are not going to need them:
    ipkg remove e2fsprogs libuuid
  • And then, we try to mount the USB as a drive:
    mkdir /mnt/usbmount \
      /dev/scsi/host0/bus0/target0/lun0/part1 /mnt/usb
  • Mount the USB automatically during startup is done by /etc/init.d/usb. Unfortunatelly it seemed to run too early. So let it run as late as possible - edit /etc/init.d/usb - modify START=98 and refresh the links inside rc.d directory and reboot using following commands:
    /etc/init.d/usb enable
    reboot

Learn ipkg to install to your USB drive

As described in this paragraph.

  • Create ipkg destination:
    echo dest usb /mnt/usb >> /etc/ipkg.conf
  • Create ipkg-link script which makes symbolic links to the root user, so you can run any installed software without specifying directory. Copy the source of ipkg-link from here.

Now you can simply install any sw using these 2 steps:

ipkg -dest usb install libncurses
ipkg-link add libncurses

Time to install Python

  • Probably you will first need to manually install libreadline library (or you can skip this step and see whether the installation of Python fails. This “patch” is descibed here.
    ipkg -dest usb install http://downloads.openwrt.org/..
      ..kamikaze/7.06/brcm47xx-2.6/packages/..
      ..libreadline_5.1-1_mipsel.ipk
    ipkg-link add libreadline
  • Install Python:
    ipkg -dest usb install python
    ipkg-link add libexpat
    ipkg-link add libopenssl
    ipkg-link add libpthread
    ipkg-link add uclibcxx
    ipkg-link add zlib
    ipkg-link add python
  • And also you gonna need some editor. For example I like joe.
    ipkg -dest usb install joe
    ipkg-link add joe

Configuring HTTPD to read from USB and to support Python scripts

There is already installed httpd server as a part of BusyBox. You just need to reconfigure it.

  • Change line START to value START=99 inside file /etc/init.d/httpd and e.g. following:
    [ -d /mnt/usb/www ] && httpd -p 80 \
       -h /mnt/usb/www -r ${hostname:-OpenWrt}
  • Refresh START value in rc.d and reboot:
    /etc/init.d/httpd enable
    reboot
  • Now you just need to create /mnt/usb/www and /mnt/usb/www/cgi-bin. Inside cgi-bin create some script and chmod a+x script.cgi. Try e.g. this script:
    #!/usr/bin/python
    print "Content-Type: text/html; charset=ISO-8859-2\n\n"
     
    import os
    import httplib
    import datetime
     
    def run(cmd):
      d = datetime.datetime.now()
      print '<pre>'
      toChild, fromChild, childError = os.popen3(cmd)
      for l in fromChild:
        print l,
      print '</pre>
    Duration: %s' % (datetime.datetime.now() - d)
     
    print '
    <h2>uptime</h2>
    '
    run('uptime')
     
    print '
    <h2>ps</h2>
    '
    run('ps')
     
    print '
    <h2>df</h2>
    '
    run('df')
     
    print '
    <h2>cpu info</h2>
    '
    run('cat /proc/cpuinfo')
     
    print '
    <h2>netstat</h2>
    '
    run('netstat')

Starting wifi

  • Start wifi, set SSID and PSK2 encryption using static key:
    uci set wireless.wl0.disabled=0
    uci set wireless.cfg2.encryption=psk2
    uci set wireless.cfg2.key=some_long_key
    uci set wireless.cfg2.ssid=mySSID
    uci commit wireless && wifi
  • If you want to perform MAC filtering on wifi, create file /etc/init.d/wlmacfilter with following content:
    #!/bin/sh /etc/rc.common
    # The macfilter 2 means that the filter works in "Allow" mode.
    # Other options are: 0 - disabled, or 1 - Deny.
    # wlc ifname wl0 maclist "xx:xx:xx:xx:xx:xx xx:xx:xx:xx:xx:xx"
     
    START=47
    start() {
       wlc ifname wl0 maclist "xx:xx:xx:xx:xx:xx"
       wlc ifname wl0 macfilter 2
    }
     
     
    stop() {
       wlc ifname wl0 maclist none
       wlc ifname wl0 macfilter 0
    }

    Then do following commands:

    chmod 755 /etc/init.d/wlmacfilter
    /etc/init.d/wlmacfilter enable
    reboot
Tags:

Jak dlouho nám budou prodejci srát na hlavu?

January 6th, 2008 admin No comments

Sorry, this entry is only available in Czech.

Tags: