<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Using uci-defaults scripts]]></title><description><![CDATA[<p dir="auto">I have used uci-defaults script in my image creation to setup some parameters on my onion. However one setup set that requires the devices MAC has me stumped. I need to echo the MAC into a mosquitto mqtt configuration file so I have setup a uci script called "52_mosquitto_config"</p>
<pre><code>#!/bin/sh

# Script to update MAC in mosquitto configuration
echo "Get uppercase MAC address without colons from system config"
MAC=$(cat /sys/class/net/ra0/address | sed s/://g | sed y/[abcdef]/[ABCDEF]/)

echo "Configuring Mosquitto (/etc/mosquitto/mosquitto.conf) with $MAC"
#replace the placeholder &lt;MAC&gt; in the file with the actual MAC address
sed -i "s/&lt;MAC&gt;/$MAC/" /etc/mosquitto/mosquitto.conf

exit 0

</code></pre>
<p dir="auto">however this always results in a my placeholder "&lt;MAC&gt;" being replaced with "000000000000".</p>
<p dir="auto">This led me to the conclusion that the file /sys/class/net/ra0/address is returning 00:00:00:00:00:00 at the point that uci is running.</p>
<p dir="auto">However in uci-defaults/ file "13_hostname"  they clearly use the same file to set hostname:</p>
<pre><code>m1=$(cat /sys/class/net/ra0/address | awk -F':' '{ print $5 }' | awk '{print toupper($0)}')
m2=$(cat /sys/class/net/ra0/address | awk -F':' '{ print $6 }' | awk '{print toupper($0)}')
</code></pre>
<p dir="auto">My understanding of uci-defaults is that they are run sequentially based on name.</p>
<p dir="auto">Why does mac return a valid response for script 13_hostname and not for me in 52_mosquitto_config?</p>
<p dir="auto">Any help always appreciated.</p>
<p dir="auto">Thanks.</p>
]]></description><link>http://community.onion.io/topic/4389/using-uci-defaults-scripts</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 23:09:09 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/4389.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 Jan 2021 14:43:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using uci-defaults scripts on Mon, 18 Jan 2021 14:43:07 GMT]]></title><description><![CDATA[<p dir="auto">I have used uci-defaults script in my image creation to setup some parameters on my onion. However one setup set that requires the devices MAC has me stumped. I need to echo the MAC into a mosquitto mqtt configuration file so I have setup a uci script called "52_mosquitto_config"</p>
<pre><code>#!/bin/sh

# Script to update MAC in mosquitto configuration
echo "Get uppercase MAC address without colons from system config"
MAC=$(cat /sys/class/net/ra0/address | sed s/://g | sed y/[abcdef]/[ABCDEF]/)

echo "Configuring Mosquitto (/etc/mosquitto/mosquitto.conf) with $MAC"
#replace the placeholder &lt;MAC&gt; in the file with the actual MAC address
sed -i "s/&lt;MAC&gt;/$MAC/" /etc/mosquitto/mosquitto.conf

exit 0

</code></pre>
<p dir="auto">however this always results in a my placeholder "&lt;MAC&gt;" being replaced with "000000000000".</p>
<p dir="auto">This led me to the conclusion that the file /sys/class/net/ra0/address is returning 00:00:00:00:00:00 at the point that uci is running.</p>
<p dir="auto">However in uci-defaults/ file "13_hostname"  they clearly use the same file to set hostname:</p>
<pre><code>m1=$(cat /sys/class/net/ra0/address | awk -F':' '{ print $5 }' | awk '{print toupper($0)}')
m2=$(cat /sys/class/net/ra0/address | awk -F':' '{ print $6 }' | awk '{print toupper($0)}')
</code></pre>
<p dir="auto">My understanding of uci-defaults is that they are run sequentially based on name.</p>
<p dir="auto">Why does mac return a valid response for script 13_hostname and not for me in 52_mosquitto_config?</p>
<p dir="auto">Any help always appreciated.</p>
<p dir="auto">Thanks.</p>
]]></description><link>http://community.onion.io/post/23103</link><guid isPermaLink="true">http://community.onion.io/post/23103</guid><dc:creator><![CDATA[UFD]]></dc:creator><pubDate>Mon, 18 Jan 2021 14:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to Using uci-defaults scripts on Tue, 19 Jan 2021 01:08:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/4416">@UFD</a> I hit this issue some time ago, I use a hotplug script to achieve a similar outcome to what you require.</p>
<p dir="auto">Here is my script:</p>
<p dir="auto">#!/bin/sh</p>
<h1></h1>
<h1>File:   40-setup</h1>
<h1>Author: chris</h1>
<h1></h1>
<h1>Created on 24 Jun. 2019, 1:07:07 am</h1>
<h1></h1>
<p dir="auto">#!/bin/sh</p>
<h1>Place me in /etc/hotplug.d/iface/40-setup</h1>
<p dir="auto">WIFI_INTERFACE="wwan"<br />
m1=$(cat /sys/class/net/ra0/address | awk -F':' '{ print $3$4$5$6 }' | awk '{print toupper($0)}')</p>
<p dir="auto">echo  "Starting interace hotplug ${DEVICE} Action: ${ACTION} Interface: ${INTERFACE}" &gt;&gt; /tmp/cblog<br />
if [ "$ACTION" = "ifup" -a "$INTERFACE" = "wwan" ]; then<br />
echo "IFUP ${DEVICE}" &gt;&gt; /tmp/cblog<br />
rm -f /etc/hotplug.d/iface/40-setup<br />
echo "Run script for device: ${DEVICE}" &gt;&gt; /tmp/cblog<br />
echo "nameserver $(ip -o -4 a s apcli0 | awk '{ print $4 }' | cut -d/ -f1)" &gt;&gt; /etc/resolv.conf</p>
<p dir="auto">//## Insert command to use MAC<br />
fi</p>
]]></description><link>http://community.onion.io/post/23104</link><guid isPermaLink="true">http://community.onion.io/post/23104</guid><dc:creator><![CDATA[crispyoz]]></dc:creator><pubDate>Tue, 19 Jan 2021 01:08:58 GMT</pubDate></item><item><title><![CDATA[Reply to Using uci-defaults scripts on Wed, 20 Jan 2021 00:45:13 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/6184">@crispyoz</a>.</p>
<p dir="auto">I have tried this workaround but i must have done something wrong as my file did not seem to want to run.</p>
<p dir="auto">Another workaround I did however findis to use the ethernet mac address and derive the wifi one in the uci script. Seems the ra0 interface mac is only available once the wifi drivers are loaded which seems to be after uci-defaults scripts. however ethernet MAC is available and wifi mac can be derived by subtracting 1.</p>
<p dir="auto">My updated script as shared before is now:</p>
<pre><code>#!/bin/sh

# Script to update MAC in mosquitto configuration
echo "Get uppercase WiFi MAC address without colons from system config"
EMAC=$(cat /sys/class/net/eth0/address | sed s/://g | sed y/[abcdef]/[ABCDEF]/)
WMAC=$(printf "%X" $((0x${EMAC} - 1)))

echo "Configuring Mosquitto (/etc/mosquitto/mosquitto.conf) with $WMAC"
#replace the placeholder &lt;MAC&gt; in the file with the actual WMAC address
sed -i "s/&lt;MAC&gt;/$WMAC/" /etc/mosquitto/mosquitto.conf

exit 0
</code></pre>
<p dir="auto">It will however continue to bug me as to why the original uci script did not work... I wonder how the omega onion official 13_hostname is actually doing anything when I overwrite this file with a debug version to print its mac also shows up as 00:00:00:00:00:00.</p>
<p dir="auto">Maybe we will never know.</p>
<p dir="auto">Thanks.</p>
]]></description><link>http://community.onion.io/post/23110</link><guid isPermaLink="true">http://community.onion.io/post/23110</guid><dc:creator><![CDATA[UFD]]></dc:creator><pubDate>Wed, 20 Jan 2021 00:45:13 GMT</pubDate></item><item><title><![CDATA[Reply to Using uci-defaults scripts on Wed, 20 Jan 2021 23:39:22 GMT]]></title><description><![CDATA[<p dir="auto">For the interested:<br />
I found that MAC can also be obtained on a more lower level:</p>
<pre><code>hexdump -s 4 -n 6 /dev/mtd2 | sed -n '1p' | awk '{print substr($2,3) substr($2,1,2) substr($3,3) substr($3,1,2) substr($4,3) substr($4,1,2)}'
</code></pre>
<p dir="auto">as seen in the ethernet-mode init.d script</p>
]]></description><link>http://community.onion.io/post/23120</link><guid isPermaLink="true">http://community.onion.io/post/23120</guid><dc:creator><![CDATA[UFD]]></dc:creator><pubDate>Wed, 20 Jan 2021 23:39:22 GMT</pubDate></item></channel></rss>