文中以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脚本。