[openwrt] move sensor config loading at firstboot to flukso init script

This commit is contained in:
Bart Van Der Meerssche 2011-03-24 21:56:56 +01:00
parent 90f4f8be8c
commit cf45925c44
3 changed files with 36 additions and 30 deletions

View File

@ -1,9 +1,10 @@
config system config system
option timezone UTC option timezone UTC
option hostname flukso option hostname flukso
option device 0123456789abcdef0123456789abcdef option device 0123456789abcdef0123456789abcdef
option key 00112233445566778899aabbccddeeff option key 00112233445566778899aabbccddeeff
option version 210 option version 210
option firstboot 1
config button config button
option button reset option button reset

View File

@ -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

View File

@ -3,14 +3,42 @@
START=98 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 chmod 666 /dev/spidev0.0
/usr/sbin/spid /usr/sbin/spid
/usr/sbin/fluksod /usr/sbin/fluksod
} }
stop() { stop()
{
/usr/sbin/fluksod -k /usr/sbin/fluksod -k
/usr/sbin/spid -k /usr/sbin/spid -k