Installation

Flash OpenWrt firmware

Attach your router and connect via webbrowser at http://192.168.1.1 with user “admin” and password “admin”. Go to SystemTools ‣ Firmware Upgrade and flash with OpenWrt firmware image downloaded from http://lightrouter.googlecode.com/files/openwrt-lightrouter-final-10-factory.bin

Basic Configuration

Password

After reboot set password login via telnet and set password to kuffner12568 (in Windows use Putty):

telnet 192.168.1.1

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

Logout & Login via ssh root@192.168.1.1 (in Windows use Putty). Login via webbrowser at http://192.168.1.1 with user "root" and password "kuffner12568".

System Settings

Set hostname in System ‣ System

Led configuration System ‣ LED Configuration

_images/LEDConfiguration.png

Or change /etc/config/system to:

config 'system'
	option 'hostname' 'atdurrenstein'
	option 'timezone' 'UTC'

config 'rdate'
	option 'interface' 'wan'

config 'led' 'wlan_led'
	option 'name' 'WLAN'
	option 'default' '0'
	option 'sysfs' 'tl-wr1043nd:green:wlan'
	option 'trigger' 'phy0rx'

config 'led'
	option 'default' '0'
	option 'name' 'Heartbeat'
	option 'sysfs' 'tl-wr1043nd:green:qss'
	option 'trigger' 'heartbeat'

Storage

Attach USB-Stick and check connection:

root@OpenWrt:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 004: ID 19d2:0117 ONDA Communication S.p.A.


root@OpenWrt:~# dmesg
usb-storage: device found at 4
usb-storage: waiting for device to settle before scanning
scsi 1:0:0:0: Direct-Access     ZTE      MMC Storage      2.31 PQ: 0 ANSI: 2
usb-storage: device scan complete
sd 1:0:0:0: [sda] 3866624 512-byte logical blocks: (1.97 GB/1.84 GiB)
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Mode Sense: 0f 0e 00 00
sd 1:0:0:0: [sda] Assuming drive cache: write through
sd 1:0:0:0: [sda] Assuming drive cache: write through
 sda: sda1
sd 1:0:0:0: [sda] Assuming drive cache: write through
sd 1:0:0:0: [sda] Attached SCSI removable disk

root@OpenWrt:~# fdisk -l

Disk /dev/sda: 1979 MB, 1979711488 bytes
1 heads, 62 sectors/track, 62364 cylinders
Units = cylinders of 62 * 512 = 31744 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1   *           3       62365     1933247+  c Win95 FAT32 (LBA)

Create partition:

root@OpenWrt:~# fdisk /dev/sda

The number of cylinders for this disk is set to 5139.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1322, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1322, default 1322): +1G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (332-1322, default 332): Using default value 332
Last cylinder or +size or +sizeM or +sizeK (332-1322, default 1322): +64M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (354-1322, default 354): Using default value 354
Last cylinder or +size or +sizeM or +sizeK (354-1322, default 1322): Using default value 1322

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap)

Command (m for help): p

Disk /dev/sda: 4004 MB, 4004511744 bytes
116 heads, 51 sectors/track, 1322 cylinders
Units = cylinders of 5916 * 512 = 3028992 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1         331      979072+ 83 Linux
/dev/sda2             332         353       65076  82 Linux swap
/dev/sda3             354        1322     2866302  83 Linux


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table

Create Filesystem:

root@OpenWrt:~#  mkfs.ext4 -L lroot /dev/sda1
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=lroot
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
62744 inodes, 250044 blocks
12502 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
31 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

root@OpenWrt:~#  mkfs.ext4 -L lhome /dev/sda3
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=lhome
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
97536 inodes, 389546 blocks
19477 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=402653184
12 block groups
32768 blocks per group, 32768 fragments per group
8128 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.s first.  Use tune2fs -c or -i to override.


root@OpenWrt:~#  mkswap /dev/sda2
Setting up swapspace version 1, size = 79609856 bytes
UUID=0f10c589-fce3-4f20-9c99-5ec49b4c23f2
root@lightkuffner:~#

Edit mount points in Luci System ‣ Mountpoints

_images/MountPoints10.png

Or change /etc/config/fstab to:

config 'global' 'automount'
	option 'from_fstab' '1'
	option 'anon_mount' '1'

config 'global' 'autoswap'
	option 'from_fstab' '1'
	option 'anon_swap' '0'

config 'mount'
	option 'device' '/dev/sda1'
	option 'fstype' 'ext4'
	option 'enabled_fsck' '1'
	option 'enabled' '1'
	option 'label' 'lroot'
	option 'options' 'rw,relatime,barrier=1,data=ordered'
	option 'is_rootfs' '1'

config 'swap'
	option 'device' '/dev/sda2'
	option 'enabled' '1'

config 'mount'
	option 'enabled' '1'
	option 'device' '/dev/sda3'
	option 'label' 'lhome'
	option 'target' '/home'
	option 'fstype' 'ext4'
	option 'options' 'rw,relatime,barrier=1,data=ordered'

Create new root filesystem on usb-stick:

umount /dev/sda1
mount /dev/sda1 /mnt
rm -rf /mnt/*
mkdir /tmp/root
mount -o bind / /tmp/root
cp -a /tmp/root/* /mnt
umount /tmp/root
umount /mnt
mkdir /home

Reboot System:

root@OpenWrt:~# reboot

Check mount points:

root@atkuffner:/home/light# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
/dev/sda1 on /overlay type ext4 (rw,relatime,barrier=1,data=ordered)
mini_fo:/overlay on / type mini_fo (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sda3 on /home type ext4 (rw,relatime,barrier=1,data=ordered)
none on /proc/bus/usb type usbfs (rw,relatime)

root@atkuffner:/home/light# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 6.1M      6.1M         0 100% /rom
tmpfs                    14.4M    296.0K     14.1M   2% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1                 3.8G     99.7M      3.5G   3% /overlay
mini_fo:/overlay          6.1M      6.1M         0 100% /
/dev/sda3                 3.5G    263.6M      3.0G   8% /home

Create directories:

mkdir /home/down

UMTS

Add UMTS Interface in Network ‣ Interfaces

_images/InterfacesUwanCreate.png _images/InterfacesUwanSetup.png _images/InterfacesUwanFirewall.png

Or change /etc/config/network to:

config 'interface' 'loopback'
	option 'ifname' 'lo'
	option 'proto' 'static'
	option 'ipaddr' '127.0.0.1'
	option 'netmask' '255.0.0.0'

config 'interface' 'lan'
	option 'ifname' 'eth0.1'
	option 'type' 'bridge'
	option 'proto' 'static'
	option 'ipaddr' '192.168.1.1'
	option 'netmask' '255.255.255.0'

config 'interface' 'wan'
	option 'ifname' 'eth0.2'
	option 'proto' 'dhcp'

config 'switch'
	option 'name' 'rtl8366rb'
	option 'reset' '1'
	option 'enable_vlan' '1'

config 'switch_vlan'
	option 'device' 'rtl8366rb'
	option 'vlan' '1'
	option 'ports' '1 2 3 4 5t'

config 'switch_vlan'
	option 'device' 'rtl8366rb'
	option 'vlan' '2'
	option 'ports' '0 5t'

config 'interface' 'uwan'
	option 'ifname' 'ppp0'
	option 'proto' '3g'
	option 'service' 'umts'
	option 'apn' 'web.yesss.at'
	option 'pincode' '2175'
	option 'device' '/dev/ttyUSB2'
	option 'username' 'root'
	option 'password' 'kuffner12568'
	option 'keepalive' '60'
	option 'maxwait' '60'

Update usb_modswitch script:

cd /home/down/
wget http://lightrouter.googlecode.com/files/usb_modswitch_19d2_0117
cp usb_modswitch_19d2_0117 /etc/usb_modeswitch.d/19d2\:0117

GPSD

Change /etc/init.d/gpsd to:

#!/bin/sh /etc/rc.common
# Copyright (C) 2009 OpenWrt.org
START=50

NAME=gpsd
PIDF=/var/run/$NAME.pid
PROG=/usr/sbin/$NAME

start() {
    config_load gpsd
    config_get device core device
    config_get port core port
    config_get_bool enabled core enabled
    [ "$enabled" != "1" ] && exit
    logger -t "$NAME" "Starting..."
    [ ! -c "$device" ] && {
        logger -t "$NAME" "Unable to find device $device. Exiting."
        exit 1
    }
    # $PROG -n -P $PIDF -S $port $device
    $PROG -n -N -G -P $PIDF -S $port $device > /dev/null 2>&1 &
}

stop() {
    logger -t "$NAME" "Stopping..."
    [ -f "$PIDF" ] && {
        read PID < "$PIDF"
        kill -9 $PID
        rm $PIDF
    }
}

Change /etc/ntp.conf to:

# use a random selection of 8 public stratum 2 servers
# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers

#restrict default nomodify notrap noquery
#restrict default noquery


restrict 127.0.0.1

driftfile  /tmp/ntp.drift

#server 0.openwrt.pool.ntp.org iburst
#server 1.openwrt.pool.ntp.org iburst
#server 2.openwrt.pool.ntp.org iburst
#server 3.openwrt.pool.ntp.org iburst


# GPS(NMEA)+PPS
server 127.127.20.0 minpoll 4 prefer
fudge 127.127.20.0 flag3 1 flag2 0

# SMA PPS
server 127.127.28.0 minpoll 4 prefer
fudge 127.127.28.0 refid PPS flag3 1

#server 192.168.1.253

Get gpstimesync:

mkdir /home/down
cd /home/down
wget https://bitbucket.org/Atrawog/gpstimesync/src/7a5842ac6031/gpstimesync.tar.gz
tar -xvzf gpstimesync.tar.gz
mv gpstimesync /home

Change /etc/crontabs/root to:

*/1 * * * *     date > /etc/timestamp
*/1 * * * *     /home/gpstimesync/gpstimesync.py

FixTime

Update Fixtime script:

cd /home/down/
wget http://lightrouter.googlecode.com/files/luci_fixtime
cp luci_fixtime /etc/init.d
chmod 755 /etc/init.d/luci_fixtime

Statistics

Create directory for statistics:

mkdir /home/rrd
mkdir /home/rrd/image
mkdir /home/rrd/data

Change output directory in Statistics ‣ Collectd ‣ Output plugins ‣ RRDTools

_images/CollectdRRD.png

Or change /etc/config/luci_statistics to:

config 'statistics' 'rrdtool'
        option 'default_timespan' '1hour'
        option 'image_width' '600'
        option 'image_path' '/home/rrd/imgag'

config 'statistics' 'collectd'
	option 'BaseDir' '/var/run/collectd'
	option 'Include' '/etc/collectd/conf.d'
	option 'PIDFile' '/var/run/collectd.pid'
	option 'PluginDir' '/usr/lib/collectd'
	option 'TypesDB' '/usr/share/collectd/types.db'
	option 'Interval' '30'
	option 'ReadThreads' '2'

config 'statistics' 'collectd_ping'
	option 'enable' '0'
	option 'TTL' '127'
	option 'Interval' '30'
	option 'Hosts' '127.0.0.1'

config 'statistics' 'collectd_csv'
	option 'enable' '0'
	option 'StoreRates' '0'
	option 'DataDir' '/tmp'

config 'statistics' 'collectd_df'
	option 'enable' '0'
	option 'Devices' '/dev/mtdblock/4'
	option 'MountPoints' '/jffs'
	option 'FSTypes' 'tmpfs'
	option 'IgnoreSelected' '0'

config 'statistics' 'collectd_disk'
	option 'enable' '0'
	option 'Disks' 'hda1 hdb'
	option 'IgnoreSelected' '0'

config 'statistics' 'collectd_dns'
	option 'enable' '0'
	option 'Interfaces' 'ffdhcp ff br-lan'
	option 'IgnoreSources' '127.0.0.1'

config 'statistics' 'collectd_email'
	option 'enable' '0'
	option 'SocketFile' '/var/run/collectd/email.sock'
	option 'SocketGroup' 'nogroup'

config 'statistics' 'collectd_exec'
	option 'enable' '1'

config 'collectd_exec_input'
	option 'cmdline' '/usr/bin/stat-input-olsr'

config 'collectd_exec_notify'
	option 'cmdline' '/usr/bin/stat-output-syslog'

config 'statistics' 'collectd_interface'
	option 'enable' '1'
	option 'Interfaces' 'br-lan br-ff'
	option 'IgnoreSelected' '0'

config 'statistics' 'collectd_iptables'
	option 'enable' '1'

config 'collectd_iptables_match'
	option 'table' 'nat'
	option 'chain' 'luci_fw_postrouting'
	option 'target' 'MASQUERADE'
	option 'source' '192.168.1.0/24'
	option 'outputif' 'br-ff'
	option 'name' 'Verkehr LAN-Clients'

config 'collectd_iptables_match'
	option 'chain' 'luci_fw_postrouting'
	option 'table' 'nat'
	option 'target' 'MASQUERADE'
	option 'source' '10.61.230.0/24'
	option 'outputif' 'br-ff'
	option 'name' 'Verkehr WLAN-Clients'

config 'statistics' 'collectd_irq'
	option 'enable' '0'
	option 'Irqs' '2 3 4 7'

config 'statistics' 'collectd_load'
	option 'enable' '1'

config 'statistics' 'collectd_logfile'
	option 'enable' '0'
	option 'LogLevel' 'notice'
	option 'File' '/var/log/collectd.log'
	option 'Timestamp' '1'

config 'statistics' 'collectd_netlink'
	option 'enable' '0'
	option 'IgnoreSelected' '0'
	option 'VerboseInterfaces' 'br-lan br-ff'
	option 'QDiscs' 'br-lan br-ff'

config 'statistics' 'collectd_network'
	option 'enable' '0'

config 'collectd_network_listen'
	option 'host' '0.0.0.0'

config 'collectd_network_server'
	option 'host' '0.0.0.0'

config 'statistics' 'collectd_processes'
	option 'enable' '1'

config 'statistics' 'collectd_tcpconns'
	option 'enable' '1'
	option 'ListeningPorts' '0'
	option 'LocalPorts' '22 80'

config 'statistics' 'collectd_unixsock'
	option 'enable' '0'
	option 'SocketFile' '/var/run/collectd/query.sock'
	option 'SocketGroup' 'nogroup'

config 'statistics' 'collectd_wireless'
	option 'enable' '1'

config 'statistics' 'collectd_cpu'
	option 'enable' '1'

config 'statistics' 'collectd_rrdtool'
	option 'enable' '1'
	option 'DataDir' '/home/rrd/data'
	option 'RRARows' '100'
	option 'RRASingle' '1'
	option 'RRATimespans' '10min 1hour 1day 1week 1month 1year'

SSH-Keys

Create SSH keys (leave passphrase empty):

ssh-keygen -t dsa

Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.

Enable key authentification with datenscheibe.org:

scp /root/.ssh/id_dsa.pub light@datenscheibe.org:~/.ssh/atkuffner_id_dsa.pub
ssh light@datenscheibe.org "cat ~/.ssh/atkuffner_id_dsa.pub >> ~/.ssh/authorized_keys"
ssh light@datenscheibe.org "chmod 700 ~/.ssh/authorized_keys"

SSH-Tunnnel

Change /etc/config/sshtunnel to:

#
# password authentication is not possible, public key authentication must be used.
# set "option IdentityFile" to he file from which the identity (private key) for RSA or DSA authentication is read.  
# The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for protocol version 2.
# ssh will also try to load certificate information from the filename obtained by appending -cert.pub to identity filenames.
#

config server datenscheibe
	option user			light
	option hostname		        87.106.77.126
	option port			22
	option retrydelay		1	
	option CheckHostIP		no
	option Compression		yes
	option CompressionLevel		6
	option TCPKeepAlive		yes
	option VerifyHostKeyDNS		yes

config tunnelR local_ssh
        option server         datenscheibe
        option remoteaddress  *
        option remoteport     14001
        option localaddress   127.0.0.1
        option localport      22

Lightmeter

Install lightmeter software:

mkdir /home/down
mkdir /home/light
mkdir /home/log
cd /home/down
wget http://lightrouter.googlecode.com/files/lightmeter-mini-0.5.2.tar.gz
tar -xvzf lightmeter-mini-0.5.2.tar.gz
cp -r /home/down/lightmeter-mini-0.5.2 /home/lightmeter

Lightmeter check for version Mark 2.3:

/home/lightmeter/lightmeter23.py -cv

Lightmeter check for Version Mark 2.3l:

/home/lightmeter/lightmeter23l.py -cv

Local Startup

Configure local startup in Services ‣ Initscripts ‣ LocalStartup

_images/LocalStartup10.png

For UMTS change /etc/rc.local to:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
usb_modeswitch -c /etc/usb_modeswitch.d/19d2\:2000
usb_modeswitch -c /etc/usb_modeswitch.d/19d2\:0117
date >> /home/log/lightmeter.log
/usr/bin/python /home/lightmeter/lightmeter23l.py  -c -n AT_Kuffner -o /home/light/ -a -B 8000 >> /home/log/lightmeter.log  2>&1 &
sleep 60
ifup uwan

exit 0

Scheduled Task

Configure scheduled task in Services ‣ Scheduled Tasks

_images/ScheduledTasks10.png

Or change /etc/crontabs/root to:

*/5 * * * *	killall -HUP dnsmasq
#* * * * *		/usr/sbin/ff_olsr_test_gw
#*/5 * * * *	/usr/sbin/ff_olsr_watchdog
#0 */4 * * *	/usr/sbin/ff_rdate
#17 * * * *	/usr/sbin/ff_mapupdate
*/1 * * * *     date > /etc/timestamp
55 * * * *     ifup uwan
0 * * * *     date >> /home/log/rsync.log
1 * * * *     /usr/bin/rsync -avz /home/light/* light@87.106.77.126:/home/light/atkuffner >> /home/log/rsync.log  2>&1

Sysupgrade

Change /etc/sysupgrade.conf to:

## This file contains files and directories that should
## be preserved during an upgrade.

/etc/init.d/luci_fixtime
/etc/crontabs/root
/etc/usb_modeswitch.d/19d2:0117
/etc/timestamp
/root

Save configuration

Copy config to USB-Stick:

mkdir /home/backup
mkdir /home/backup/uci
rsync -av --delete /etc /home/backup
rsync -av --delete /root /home/backup
uci export > /home/backup/uci/uci.export

Restore configuration

Restore config and lightmeter files:

cp /home/backup/etc/rc.local /etc
cp /home/backup/etc/init.d/luci_fixtime /etc/init.d
cp /home/backup/etc/crontabs/root /etc/crontabs
cp -r /home/down/lightmeter-mini-0.5.2 /lightmeter
cp /home/backup/etc/usb_modeswitch.d/19d2:0117 /etc/usb_modeswitch.d