Press "Enter" to skip to content

Tag: openwrt

OpenWrt路由器获取系统信息

我的OpenWrt路由器信息

cat /etc/openwrt_release
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='23.05.3'
DISTRIB_REVISION='r23809-234f1a2efa'
DISTRIB_TARGET='mediatek/filogic'
DISTRIB_ARCH='aarch64_cortex-a53'
DISTRIB_DESCRIPTION='OpenWrt 23.05.3 r23809-234f1a2efa'


cat /etc/os-release
NAME="OpenWrt"
VERSION="21.02-SNAPSHOT"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 21.02-SNAPSHOT"
VERSION_ID="21.02-snapshot"
HOME_URL="https://openwrt.org/"
BUG_URL="https://bugs.openwrt.org/"
SUPPORT_URL="https://forum.openwrt.org/"
BUILD_ID="r15812+885-46b6ee7ffc"
OPENWRT_BOARD="mediatek/mt7981"
OPENWRT_ARCH="aarch64_cortex-a53"
OPENWRT_TAINTS="no-all busybox"
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt 21.02-SNAPSHOT r15812+885-46b6ee7ffc"


. /etc/openwrt_release && echo "$DISTRIB_RELEASE"
21.02-SNAPSHOT


. /etc/openwrt_release && echo "$DISTRIB_ARCH"
aarch64_cortex-a53


# Get repo link
echo "https://downloads.openwrt.org/releases/$(. /etc/openwrt_release && echo "$DISTRIB_RELEASE")/packages/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")/packages"


# Write repo
echo "
src/gz openwrt_base https://downloads.openwrt.org/releases/$(. /etc/openwrt_release && echo "$DISTRIB_RELEASE")/packages/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")/base
src/gz openwrt_luci https://downloads.openwrt.org/releases/$(. /etc/openwrt_release && echo "$DISTRIB_RELEASE")/packages/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")/luci
src/gz openwrt_packages https://downloads.openwrt.org/releases/$(. /etc/openwrt_release && echo "$DISTRIB_RELEASE")/packages/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")/packages
src/gz openwrt_routing https://downloads.openwrt.org/releases/$(. /etc/openwrt_release && echo "$DISTRIB_RELEASE")/packages/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")/routing
" | tee -a "/etc/opkg/customfeeds.conf"

我的OpenWrt使用的是哪种架构的CPU?

opkg print-architecture | awk '{print $2}' | grep -v all | grep -v noarch   # 精确的命令
mips_24kc

$ uname -m    # 只能得到大致架构信息
mips

$ . /etc/openwrt_release ; echo $DISTRIB_ARCH
mips_24kc

我的OpenWrt是32位的还是64位的?

cat /proc/cpuinfo
Processor       : ARMv7 Processor rev 10 (v7l)

uname -m
armv7l    # 如果是64位系统, 这里会有64位字样出现

提示: ARMv7 都是32位CPU, armv8以上才是64位CPU.

$ echo $SHELL
/bin/ash

$ file /bin/ash
/bin/ash: symbolic link to busybox

$ which busybox
/bin/busybox

$ file /bin/busybox 
/bin/busybox: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1...
1 Comment

在OpenWrt/LEDE系统中处理JSON

在OpenWrt/LEDE系统中处理JSON的方法,这里记录一下。

假设有一个JSON文件

cat /etc/ss.json 
{
	"server": "8.8.8.8",
	"server_port": 443,
	"local_address": "0.0.0.0",
	"local_port": 7070,
	"password": "fuckgfang",
	"method": "aes_128_ctr",
	"timeout": "60",
	"protocol": "auth_aes128_sha1",
	"fast_open": false
}

处理方式1

$ jsonfilter -i /etc/ss.json -e "@.server"
8.8.8.8

$ CONF=/etc/ss.json
$ a=$(jsonfilter -i $CONF -e "@.server")
$ echo $a
8.8.8.8
1 Comment