mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 18:07:52 +00:00
83 lines
1.8 KiB
Diff
83 lines
1.8 KiB
Diff
From a791b99da9f79d73f7e665f898372cfaacacfacf Mon Sep 17 00:00:00 2001
|
|
From: Rick Sommerville <rick.sommerville@netexperience.com>
|
|
Date: Sat, 19 Dec 2020 12:07:07 -0500
|
|
Subject: [PATCH 39/40] Add /usr/bin/get_tip script for EC420
|
|
|
|
---
|
|
files/usr/bin/get_tip | 63 +++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 63 insertions(+)
|
|
create mode 100755 files/usr/bin/get_tip
|
|
|
|
diff --git a/files/usr/bin/get_tip b/files/usr/bin/get_tip
|
|
new file mode 100755
|
|
index 0000000000..e736357cdd
|
|
--- /dev/null
|
|
+++ b/files/usr/bin/get_tip
|
|
@@ -0,0 +1,63 @@
|
|
+#!/bin/sh
|
|
+#
|
|
+# Copyright (C) 2020 TP-Link
|
|
+#
|
|
+
|
|
+
|
|
+# tftp -g -l /usr/sbin/get_tip -r get_tip 192.168.0.100
|
|
+# chmod a+x /usr/sbin/get_tip
|
|
+
|
|
+MFR_PART="product_info"
|
|
+
|
|
+# for TIP data
|
|
+find_mtd_index()
|
|
+{
|
|
+ local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
|
|
+ local INDEX="${PART##mtd}"
|
|
+ echo ${INDEX}
|
|
+}
|
|
+
|
|
+find_mtd_part()
|
|
+{
|
|
+ local INDEX=$(find_mtd_index "$1")
|
|
+ local PREFIX=/dev/mtdblock
|
|
+ [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
|
|
+ echo "${INDEX:+$PREFIX$INDEX}"
|
|
+}
|
|
+
|
|
+# split manufacturing data to 2 file (deviceID and tipData)
|
|
+split_tip_data()
|
|
+{
|
|
+ local mtd_name="$1"
|
|
+ local mfr_part=$(find_mtd_part "$mtd_name")
|
|
+ if [ -z "$mfr_part" ]; then
|
|
+ echo "partition $mtd_name not found!" >&2
|
|
+ #[ -e /tmp/tip_data.bin ] && rm /tmp/tip_data.bin
|
|
+ #return
|
|
+ exit 1
|
|
+ fi
|
|
+
|
|
+ dd if=$mfr_part of=/tmp/tip_data.bin bs=1 skip=40 2>/dev/null
|
|
+}
|
|
+
|
|
+# get_tip PARTITION_NAME KEY_NAME
|
|
+if [ $# -eq 1 ]; then
|
|
+ split_tip_data $MFR_PART
|
|
+ grep "${1}=" /tmp/tip_data.bin | cut -d '=' -f 2
|
|
+ return
|
|
+elif [ $# -eq 2 ]; then
|
|
+ split_tip_data ${1}
|
|
+ grep "${2}=" /tmp/tip_data.bin | cut -d '=' -f 2
|
|
+ return
|
|
+else
|
|
+ echo "get_tip PARTITION_NAME KEY_NAME or get_tip KEY_NAME"
|
|
+fi
|
|
+
|
|
+
|
|
+
|
|
+
|
|
+
|
|
+
|
|
+
|
|
+
|
|
+
|
|
--
|
|
2.25.1
|
|
|