<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>BattleMeshV3/NodeConfigScript</title><revhistory><revision><revnumber>18</revnumber><date>2010-03-24 13:11:06</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>17</revnumber><date>2010-03-24 13:10:23</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>16</revnumber><date>2010-03-24 13:09:25</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>15</revnumber><date>2010-03-19 20:03:30</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>14</revnumber><date>2010-03-19 16:28:39</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>13</revnumber><date>2010-03-19 16:23:02</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>12</revnumber><date>2010-03-19 16:15:59</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>11</revnumber><date>2010-02-27 12:13:53</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>10</revnumber><date>2010-02-26 19:42:44</date><authorinitials>ip-62-235-238-228.dsl.scarlet.be</authorinitials></revision><revision><revnumber>9</revnumber><date>2010-02-26 19:41:16</date><authorinitials>ip-62-235-238-228.dsl.scarlet.be</authorinitials></revision><revision><revnumber>8</revnumber><date>2010-02-26 19:40:28</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>7</revnumber><date>2010-02-26 19:39:49</date><authorinitials>ip-62-235-238-228.dsl.scarlet.be</authorinitials></revision><revision><revnumber>6</revnumber><date>2010-02-26 19:39:40</date><authorinitials>ip-62-235-238-228.dsl.scarlet.be</authorinitials></revision><revision><revnumber>5</revnumber><date>2010-02-26 19:39:08</date><authorinitials>ip-62-235-238-228.dsl.scarlet.be</authorinitials></revision><revision><revnumber>4</revnumber><date>2010-02-26 19:38:48</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>3</revnumber><date>2010-02-26 19:38:08</date><authorinitials>ip-62-235-238-228.dsl.scarlet.be</authorinitials></revision><revision><revnumber>2</revnumber><date>2010-02-26 19:36:56</date><authorinitials>ptr_here</authorinitials></revision><revision><revnumber>1</revnumber><date>2010-02-26 19:26:15</date><authorinitials>ptr_here</authorinitials></revision></revhistory></articleinfo><section><title>What is the NodeConfig script?</title><para>use this <ulink url="http://www.battlemesh.org/BattleMeshV3/NodeConfigScript/NodeConfig#">NodeConfig</ulink> 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. </para><para>usage of the attached scripts: </para><itemizedlist><listitem override="none"><para>./telnet-loop.sh nodetable.csv nodeconfigscript </para></listitem></itemizedlist><para>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. </para><para>the variant ssh-loop.sh uses ssh to connect to the nodes -- use ssh keys to connect without having to enter passwords...  </para><para>use copy-loop.sh to copy files over to all of the nodes listed in your table. </para></section><section><title>Files</title></section><section><title>Basic configuration</title><itemizedlist><listitem><para><ulink url="http://www.battlemesh.org/BattleMeshV3/NodeConfigScript/BattleMeshV3/NodeConfigScript/Zlan#">BattleMeshV3/NodeConfigScript/Zlan</ulink> is a general configuration (gateway to the internet  on wired side etc) </para></listitem><listitem><para><ulink url="http://www.battlemesh.org/BattleMeshV3/NodeConfigScript/BattleMeshV3/NodeConfigScript/Olsr#">BattleMeshV3/NodeConfigScript/Olsr</ulink>  configuration of basic olsr node </para></listitem><listitem><para><ulink url="http://www.battlemesh.org/BattleMeshV3/NodeConfigScript/BattleMeshV3/NodeConfigScript/Babel#">BattleMeshV3/NodeConfigScript/Babel</ulink> configuration of babel node </para></listitem><listitem><para><ulink url="http://www.battlemesh.org/BattleMeshV3/NodeConfigScript/BattleMeshV3/NodeConfigScript/Batman#">BattleMeshV3/NodeConfigScript/Batman</ulink> configuration of batman node </para></listitem></itemizedlist></section><section><title>Snippets</title><para>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. </para><section><title>using parameters</title><para>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. </para><para>eg.  if you specified an ip address in the 4th column  </para><para><code> IP=&quot;@PARAM3@&quot; </code> </para></section><section><title>setting hostname</title><screen><![CDATA[set -a
NAME="@PARAM1@"
sysctl -w kernel.hostname=$NAME
uci set system.@system[0].hostname=$NAME
uci commit]]></screen></section><section><title>wireless device name</title><para>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') </para><screen><![CDATA[DEVICE=`uci get wireless.@wifi-iface[0].device`]]></screen><para>and then use it further in your script, eg. </para><screen><![CDATA[uci set wireless.$DEVICE.channel=4]]></screen></section><section><title>configure wireless interface</title><screen><![CDATA[set -a
# adapt PARAM2 to the parameter in your node table
IP="@PARAM2@"
#query wireless device' name
DEVICE=`uci get wireless.@wifi-iface[0].device`
]]><![CDATA[
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=255.255.255.0
]]><![CDATA[
# commit uci changes and restart wifi
uci commit wireless && wifi]]></screen></section><section><title>disabling dnsmasq, firewall, httpd</title><screen><![CDATA[set -a
]]><![CDATA[
/etc/init.d/dnsmasq stop
/etc/init.d/dnsmasq disable
]]><![CDATA[
/etc/init.d/firewall stop
/etc/init.d/firewall disable
]]><![CDATA[
/etc/init.d/httpd stop
/etc/init.d/httpd disable]]></screen></section><section><title>configuring an alias ethernet interface</title><para>as it is mandatory to keep the wired interface configured with it's default settings (ip 192.168.1.1/24) 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.  </para><para>eg. </para><screen><![CDATA[WIREDIP="@PARAM2@"
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=255.255.255.0
uci commit]]></screen></section><section><title>rc.local</title><para>executing commands after booting -- quick and dirty </para><para>eg. (PARAM7 parameter contained a static routing configuration in this case: 'route add -net 192.168.3.0/24 gw 192.168.13.1 &amp;&amp; route add -net 192.168.13.0/24 gw 192.168.4.1'  ) </para><screen><![CDATA[cat > /etc/rc.local << EOF
]]><![CDATA[
echo 1 > /proc/sys/net/ipv4/ip_forward
eval "@PARAM7@"
exit 0
EOF]]></screen></section><section><title>reset a configured node to default config</title><para>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. </para><para>executing the openwrt command  </para><para><code> firstboot </code> </para><para>will cleanup the jffs partition and reset the configuration to its initial state </para></section></section></article>