tty228 / luci-app-wechatpush

A plugin for OpenWRT routers to send various information notifications to a mobile phone via WeChat or Telegram.
GNU General Public License v2.0
1.06k stars 372 forks source link

请教代码的作用 #109

Closed Twinzo1 closed 3 years ago

Twinzo1 commented 3 years ago

请问在root/usr/bin/serverchan/serverchann39-41行的作用是什么

for read_str in "ip_version" "cu_version"; do
    [ -z `eval echo '$'$read_str` ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】依赖项未安装" >> ${logfile} && return 1
done

在x86中不能启动,就是因为这里return了,注释掉后就没有问题 环境:32位N270 5.4.51内核自编译lean lede

tty228 commented 3 years ago

14-17 行 从 软件包列表中 读取 wrtbwmon 、iputils-arping、curl、 iw 依赖项的名称和版本号,如果存在,创建变量 软件名前两位_version

for str_version in "wrtbwmon" "iputils-arping" "curl" "iw"; do
    eval `echo ${str_version:0:2}"_version"`=`opkg list-installed|grep -w ^${str_version}|awk '{print $3}'` 2>/dev/null
done

39-41 行

for read_str in "ip_version" "cu_version"; do
    [ -z `eval echo '$'$read_str` ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】依赖项未安装" >> ${logfile} && return 1
done

因为有段时间,某些设备不知道什么原因,在未安装依赖项的情况下,还是成功安装了插件,导致运行异常 确认依赖有安装的话,39-41 行是可以删掉的 依赖项作用: wrtbwmon 流量统计(硬件加速、软件加速环境中无法工作) iputils-arping 探测设备是否下线,因为单纯使用 ping 命令,经常无法 ping 通休眠设备 curl 推送、检查网络状态等 iw 检查设备是否与路由 wifi 连接,如果有则跳过 ping ,但是有的软路由没有网卡,如果未安装,则不进行此检测

代码使用软件名检测,可能 x86 环境这两个依赖项的软件名有变化,导致检查失败