Commit fcbe2087 authored by Alessandro Rubini's avatar Alessandro Rubini

userspace: create hwinfo from current mac addresses if no sdb is there

The binary file commited here is the same as in binaries/: it is generated
as described in commit 7c9f0d35.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent f3534f1c
#!/bin/sh
# If there is no hwinfo, we should create it, using the default
# file and the currently-active mac addresses. This is a hack to help
# people upgrading from older wr-switch-sw releases.
#
# This script is run late, because it will have effect at next boot only.
# If we run it too early, we can't get the mac address from wr0 which does
# not exist yet.
# This allows me to pass WRS_VERBOSE=y on the command line...
if [ -n "$WRS_VERBOSE" ]; then
set -x
fi
# This kernel has no hwinfo partition (strange...)
if ! grep -q hwinfo /proc/mtd; then exit 0; fi
# Is there sdb in there? If so, nothing to do.
if /wr/bin/sdb-read /dev/mtd5ro > /dev/null; then exit 0; fi
# So, we must create an sdb file, we need the template
cp /wr/etc/sdb-for-dataflash /tmp || exit 1
# and we need the eth addresses
ethaddr=$(ifconfig eth0 | grep HWaddr | awk '{print $5}')
wraddr=$(ifconfig wr0 | grep HWaddr | awk '{print $5}')
# we lack sdb-write...
sed -i s,02:34:56:78:9A:BC,$ethaddr, /tmp/sdb-for-dataflash
sed -i s,02:34:56:78:9A:00,$wraddr, /tmp/sdb-for-dataflash
# Create the writable device file and write in there, then remove it
test -c /dev/mtd5 || mknod /dev/mtd5 c 90 10
flash_erase /dev/mtd5 0 0
cat /tmp/sdb-for-dataflash > /dev/mtd5
rm /dev/mtd5
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment