From cf45925c4426b90e914cd4e017f720984d8d683b Mon Sep 17 00:00:00 2001 From: Bart Van Der Meerssche Date: Thu, 24 Mar 2011 21:56:56 +0100 Subject: [PATCH] [openwrt] move sensor config loading at firstboot to flukso init script --- mote/v2/openwrt/files/etc/config/system | 11 ++++--- .../files/lib/firstboot/99_20_flukso_config | 23 ------------- .../openwrt/package/flukso/config/flukso.init | 32 +++++++++++++++++-- 3 files changed, 36 insertions(+), 30 deletions(-) delete mode 100644 mote/v2/openwrt/files/lib/firstboot/99_20_flukso_config diff --git a/mote/v2/openwrt/files/etc/config/system b/mote/v2/openwrt/files/etc/config/system index 3c8715c..754e65a 100644 --- a/mote/v2/openwrt/files/etc/config/system +++ b/mote/v2/openwrt/files/etc/config/system @@ -1,9 +1,10 @@ config system - option timezone UTC - option hostname flukso - option device 0123456789abcdef0123456789abcdef - option key 00112233445566778899aabbccddeeff - option version 210 + option timezone UTC + option hostname flukso + option device 0123456789abcdef0123456789abcdef + option key 00112233445566778899aabbccddeeff + option version 210 + option firstboot 1 config button option button reset diff --git a/mote/v2/openwrt/files/lib/firstboot/99_20_flukso_config b/mote/v2/openwrt/files/lib/firstboot/99_20_flukso_config deleted file mode 100644 index ac95679..0000000 --- a/mote/v2/openwrt/files/lib/firstboot/99_20_flukso_config +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2006-2010 OpenWrt.org -# Copyright (C) 2010 Vertical Communications -# Copyright (C) 2011 flukso.net - -flukso_config() { - uci set system.@system[0].key=$(hexdump -v -e '1/1 "%.2x"' -s $((0x11000)) -n 16 /dev/mtd6) - uci set system.@system[0].device=$(hexdump -v -e '1/1 "%.2x"' -s $((0x11020)) -n 16 /dev/mtd6) - uci set system.@system[0].hostname=flukso-$(hexdump -v -e '1/1 "%.2x"' -s $((0x11020)) -n 3 /dev/mtd6) - - for i in `seq 6`; - do - ADDRESS=0x110$((i+2))0 - uci set flukso.$i.id=$(hexdump -v -e '1/1 "%.2x"' -s $((ADDRESS)) -n 16 /dev/mtd6) - done - - uci commit - - echo 'configuring flukso device and sensor ids' -} - -boot_hook_add switch2jffs flukso_config diff --git a/mote/v2/openwrt/package/flukso/config/flukso.init b/mote/v2/openwrt/package/flukso/config/flukso.init index 634f30c..18a6d75 100755 --- a/mote/v2/openwrt/package/flukso/config/flukso.init +++ b/mote/v2/openwrt/package/flukso/config/flukso.init @@ -3,14 +3,42 @@ START=98 -start() { +load_config() +{ + uci set system.@system[0].key=$(hexdump -v -e '1/1 "%.2x"' -s $((0x11000)) -n 16 /dev/mtd6) + uci set system.@system[0].device=$(hexdump -v -e '1/1 "%.2x"' -s $((0x11020)) -n 16 /dev/mtd6) + uci set system.@system[0].hostname=flukso-$(hexdump -v -e '1/1 "%.2x"' -s $((0x11020)) -n 3 /dev/mtd6) + + for i in `seq 6`; + do + ADDRESS=0x110$((i+2))0 + uci set flukso.$i.id=$(hexdump -v -e '1/1 "%.2x"' -s $((ADDRESS)) -n 16 /dev/mtd6) + done + + uci set system.@system[0].firstboot='0' + uci commit + + logger 'configuring flukso device and sensor ids' +} + + +start() +{ + FIRSTBOOT=$(uci get system.@system[0].firstboot) + + if [ $FIRSTBOOT -eq '1' ] + then + load_config + fi + chmod 666 /dev/spidev0.0 /usr/sbin/spid /usr/sbin/fluksod } -stop() { +stop() +{ /usr/sbin/fluksod -k /usr/sbin/spid -k