welcome: please sign in
location: BattleMeshV3 / NodeConfigScript

What is the NodeConfig script?

use this NodeConfig scripts to easily change the configuration of any number of nodes. Just connect all nodes over the cabled ethernet network, note all the mac-addresses of the nodes you want to configure, and run the available scripts configure all of those.

usage of the attached scripts:

will connect to all nodes (one-by-one), listed in the nodetable.csv (mac-addresses, etc.) execute the nodeconfigscript _on the node. It is using the telnet daemon running on the nodes to connect.

the variant ssh-loop.sh uses ssh to connect to the nodes -- use ssh keys to connect without having to enter passwords...

use copy-loop.sh to copy files over to all of the nodes listed in your table.


  • [get | view] (2016-12-28 10:25:07, 1.2 KB) [[attachment:copy-loop.sh]]
  • [get | view] (2016-12-28 10:25:07, 1.3 KB) [[attachment:nodeconfigscript]]
  • [get | view] (2016-12-28 10:25:07, 0.8 KB) [[attachment:nodetable.csv]]
  • [get | view] (2016-12-28 10:25:07, 1.6 KB) [[attachment:ssh-loop.sh]]
  • [get | view] (2016-12-28 10:25:07, 1.5 KB) [[attachment:telnet-loop.sh]]
 All files | Selected Files: delete move to page copy to page

Basic configuration


usefull short fragments of code to script the configuration -- we use the 'uci' command to set the system configuration, as it is standard on openwrt and easy to use command line tool.

using parameters

the 'node-configuration-factory' parses the node table, and exports the parameters specified using the variable names @PARAM0@ to @PARAM9@ -- use these in your scripts for node specific parameters.

eg. if you specified an ip address in the 4th column


setting hostname

set -a
sysctl -w kernel.hostname=$NAME
uci set system.@system[0].hostname=$NAME
uci commit

wireless device name

the wireless device has different names on different types of devices -- you can query the name from the uci system (it's typically 'wifi0' or 'radio0')

DEVICE=`uci get wireless.@wifi-iface[0].device`

and then use it further in your script, eg.

uci set wireless.$DEVICE.channel=4

configure wireless interface

set -a
# adapt PARAM2 to the parameter in your node table
#query wireless device' name
DEVICE=`uci get wireless.@wifi-iface[0].device`

uci set wireless.$DEVICE.channel=5
uci set wireless.$DEVICE.disabled=0
uci set wireless.$DEVICE.hwmode=11g
uci set wireless.@wifi-iface[0].network=wlan
uci set wireless.@wifi-iface[0].mode=adhoc
uci set wireless.@wifi-iface[0].ssid=WBM2009v2-Test0
uci set wireless.@wifi-iface[0].encryption=none
uci set wireless.@wifi-iface[0].bssid=02:ca:fe:ca:ca:00
uci set wireless.@wifi-iface[0].rate=54M
uci set wireless.@wifi-iface[0].bgscan=0
uci set network.wlan=interface
uci set network.wlan.proto=static
uci set network.wlan.ipaddr=$IP
uci set network.wlan.netmask=

# commit uci changes and restart wifi
uci commit wireless && wifi

disabling dnsmasq, firewall, httpd

set -a

/etc/init.d/dnsmasq stop
/etc/init.d/dnsmasq disable

/etc/init.d/firewall stop
/etc/init.d/firewall disable

/etc/init.d/httpd stop
/etc/init.d/httpd disable

configuring an alias ethernet interface

as it is mandatory to keep the wired interface configured with it's default settings (ip for the node-configuration-factory to work -- you need to configure an alias interface if you want to use the ethernet interface with other configuration settings.


uci set network.zlan=alias
uci set network.zlan.interface=lan
uci set network.zlan.proto=static
uci set network.zlan.ipaddr=$WIREDIP
uci set network.zlan.netmask=
uci commit


executing commands after booting -- quick and dirty

eg. (PARAM7 parameter contained a static routing configuration in this case: 'route add -net gw && route add -net gw' )

cat > /etc/rc.local << EOF

echo 1 > /proc/sys/net/ipv4/ip_forward
eval "@PARAM7@"
exit 0

reset a configured node to default config

a neat, easy and clean way to reset a node is to use a feature of the squashfs+jffs filesystem: the squashfs partition contains the pristine install, while the jffs contains all configuration and added packages.

executing the openwrt command


will cleanup the jffs partition and reset the configuration to its initial state

BattleMeshV3/NodeConfigScript (last edited 2010-03-24 13:11:06 by ptr_here)