找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
楼主: wulishui

受不了原版timewol(定时唤醒)的诸多bug,现推到重写并添加更多功能、更方便使用

[复制链接]
发表于 2020-9-27 18:03 来自手机 | 显示全部楼层
改改更健康
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-9-29 00:47 | 显示全部楼层
现推到重写并添加更多功能、更方便使用
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-9-29 07:57 | 显示全部楼层
好的  看看
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-10-5 14:37 | 显示全部楼层
你说别人的脚本有问题,但其实你的脚本也有问题(与新版不兼容问题,根本不能与页面互动)
所以我又继续重写json版本,虽然写是写好了但有个问题,你这个 /usr/bin/wol -i ${ipmask} 哪里来的 就比如 ipmask=192.168.1.255
这命令参数正确吗?我是验证不了了!

我也不知道我的有没有问题,我也不用,只是放着不变看着糟心,胡乱启动看了下可以用,但命令正确与否不确定!

  1. #!/bin/sh /etc/rc.common

  2. START=99
  3. USE_PROCD=1

  4. service_triggers()
  5. {
  6.         procd_add_reload_trigger 'timewol'
  7. }

  8. get_rule() {
  9.         config_get_bool enabled "$1" 'enabled' '0'
  10.         config_get woltool "$1" 'woltool' '/usr/bin/etherwake'
  11. }

  12. run_rule() {
  13.         config_get_bool enable "$1" 'enable' '0'
  14.         config_get macaddr "$1" 'macaddr'
  15.         config_get maceth "$1" 'maceth' 'br-lan'
  16.         config_get month "$1" 'month' '*'
  17.         config_get day "$1" 'day' '*'
  18.         config_get weeks "$1" 'weeks' '*'
  19.         config_get hour "$1" 'hour' '*'
  20.         config_get minute "$1" 'minute' '0'
  21.         ipmask=$(uci -q get network.lan.ipaddr|awk -F '.' '{print $1"."$2"."$3".255"}')
  22.         [ -n "$ipmask" ] || \
  23.         ipmask=$(uci -q get network.bridge.ipaddr|awk -F '.' '{print $1"."$2"."$3".255"}')
  24.         [ "$woltool" == "/usr/bin/etherwake" ] && PROG="/usr/bin/etherwake -D -i $maceth"
  25.         [ "$woltool" == "/usr/bin/wol" ] && PROG="/usr/bin/wol -i $ipmask"
  26.         [ "$enable" -eq "0" ] || \
  27.         printf "$minute $hour $day $month $weeks $PROG $macaddr # timewol\n" >> /etc/crontabs/root
  28. }

  29. start_service() {
  30.         sed -i '/timewol/d' /etc/crontabs/root 2>/dev/null
  31.         config_load 'timewol'
  32.         config_foreach get_rule 'basic'
  33.         [ "$enabled" -eq "1" ] || return 1
  34.         config_foreach run_rule 'macclient'
  35. }
复制代码





点评

#!/bin/sh /etc/rc.common # Author=wulishui , 20200908-0915 ; START=55 start() { sumenabled=$(cat /etc/config/rebootschedule 2>/dev/null|grep -c 'option enable .1.') if [ "$sumenabled" -gt 0  详情 回复 发表于 2020-10-5 14:57
luci版本不兼容这个不关我事。1.x的luci-app拿去2.0的luci用必定有问题,连lean他们都不用2.0的luci。 之所以 /usr/bin/wol ,是因为你下载的版本不是最新的。 /usr/bin/wol 是从官方wol里来的(实实在在官方wol的l  详情 回复 发表于 2020-10-5 14:51
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-10-5 14:51 | 显示全部楼层
401626436 发表于 2020-10-5 14:37
你说别人的脚本有问题,但其实你的脚本也有问题(与新版不兼容问题,根本不能与页面互动)
所以我又继续重写 ...

luci版本不兼容这个不关我事。1.x的luci-app拿去2.0的luci用必定有问题,连lean他们都不用2.0的luci。
之所以 /usr/bin/wol ,是因为你下载的版本不是最新的。 /usr/bin/wol 是从官方wol里来的(实实在在官方wol的luci里面的),但是实际上根本不存在这个东西,我帖子里说明了,后来改成wakeonlan。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-10-5 14:57 | 显示全部楼层
本帖最后由 wulishui 于 2020-10-5 15:25 编辑
401626436 发表于 2020-10-5 14:37
你说别人的脚本有问题,但其实你的脚本也有问题(与新版不兼容问题,根本不能与页面互动)
所以我又继续重写 ...

#!/bin/sh /etc/rc.common
# Auth0r=wulishui, <wulishui@gmail.com> , 20200928

START=93


start(){
enabled=`uci get timewol.@basic[0].enabled 2>/dev/null` && ENsum=`grep -c 'enable .1.' /etc/config/timewol`
if [ "$enabled" == 1 -a "$ENsum" -gt 0 ]; then
sed -i '/timewol/d' /etc/crontabs/root 2>/dev/null
[ -s /etc/crontabs/root ] || mcronrst=1
tool=$(uci get timewol.@basic[0].tool 2>/dev/null)
ipmask=`uci get network.lan.ipaddr 2>/dev/null|awk -F '.' '{print $1"."$2"."$3".255"}'`
rulessum=$(grep -c 'macclient' /etc/config/timewol)
for i in $(seq 0 $((rulessum-1)))
do
enable=$(uci get timewol.@macclient[$i].enable 2>/dev/null)
if [ "$enable" == 1 ]; then
minute=`uci get timewol.@macclient[$i].minute 2>/dev/null` || minute="00"
hour=`uci get timewol.@macclient[$i].hour 2>/dev/null` || hour="*"
day=`uci get timewol.@macclient[$i].day 2>/dev/null` || day="*"
month=`uci get timewol.@macclient[$i].month 2>/dev/null` || month="*"
weeks=`uci get timewol.@macclient[$i].weeks 2>/dev/null` || weeks="*"
maceth=`uci get timewol.@macclient[$i].maceth 2>/dev/null` || maceth="br-lan"
[ "$tool" = "etherwake" ] && TCMD="/usr/bin/etherwake -i ${maceth}" || TCMD="/usr/bin/wakeonlan -i ${ipmask}"
macaddr=`uci get timewol.@macclient[$i].macaddr 2>/dev/null` && echo "${minute} ${hour} ${day} ${month} ${weeks} ${TCMD} ${macaddr} # By timewol" >> /etc/crontabs/root
fi
done
[ "$mcronrst" == 1 ] && /etc/init.d/cron restart
fi
}

stop() {
sed -i '/timewol/d' /etc/crontabs/root 2>/dev/null
}

远没有我的代码短小精干。我受够了config get。他原版出的问题就在config get上,当一些设置是空时,无法get到也无法容错,运行错误命令导致整个系统都受波及,当看到那条错误命令时,我自己都吓了一大跳。我这些命令是有充分容错的。实际我也没用过,但是etherwake和wakeonlan我都运行-h来看过命令的用法的。config get真很多问题的,遇到过好几个程序运行错误最后查出出在这个东西上。凡是我写的、我修改的,无一例外绝不使用config get


我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-10-6 22:00 | 显示全部楼层
您的帖子一定要支持
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-10-19 01:33 | 显示全部楼层
支持。。。。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-10-22 00:37 | 显示全部楼层
看看怎么样
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-23 15:37 | 显示全部楼层
看看插件谢谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-24 15:47 来自手机 | 显示全部楼层
虽然不用,支持一下下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-26 02:38 | 显示全部楼层

感谢分享,我来顶贴
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-28 20:16 | 显示全部楼层
学习学习,谢谢分享!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-12-30 14:19 | 显示全部楼层
凑凑,谢谢拉
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2021-1-22 20:23 | 显示全部楼层

谢谢楼主分享!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-19 10:30

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表