openwrt路由器关闭灯光

文中以QWRT R24.3.3为例,finalshell登录ssh:

finalshell不显示文件,开启sftp解决

finalshell显示文件可以不用vim命令直接就编辑了

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install vsftpd openssh-sftp-server
root@OpenWrt:~# /etc/init.d/vsftpd enable
root@OpenWrt:~# /etc/init.d/vsftpd start

创建关灯文件

写入off_leds.sh

vim /etc/off_leds.sh

写入以下内容:

#!/bin/ash
for i in /sys/class/leds/*
do
  echo 0 > "$i/brightness"
done

赋予权限

chmod a+x /etc/off_leds.sh

执行

/etc/off_leds.sh

定时任务:直接qwrt设置crontab,我没设置

0 22 * * * /etc/off_leds.sh 
0 7 * * * /etc/init.d/led start
第一行会在每天晚上 10 点(22:00)执行 /etc/off_leds.sh 脚本来关闭 LED 灯。
第二行会在每天早上 7 点(07:00)执行 /etc/init.d/led start 来开启 LED 灯。

开机启动off_leds.sh脚本

vi /etc/init.d/off_leds

写入以下内容:

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
 
START=99
 
start() {
    /etc/off_leds.sh
}

赋予权限

chmod a+x /etc/init.d/off_leds

启用服务

/etc/init.d/off_leds enable

启动服务

/etc/init.d/off_leds start

开机启动off_leds.sh脚本直接放到目录 /etc/profile.d/ 下也可以

将写好的脚本(.sh文件)放到目录 /etc/profile.d/ 下,
系统启动后就会自动执行该目录下的所有shell脚本。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值