优化代码,添加若干快捷指令

使用方法:
autoupdate 更新固件
AutoUpdate 更新固件
Tools 运行 AutoBuild_Tools.sh 脚本
tools 运行 AutoBuild_Tools.sh 脚本
coremarkd 运行优化后的 /etc/coremark.sh 脚本
shutdown 同 poweroff 关机操作
This commit is contained in:
Hyy2001X 2021-04-27 19:35:49 +08:00 committed by GitHub
parent 47101622df
commit 91a771b9a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 17 deletions

View File

@ -1,11 +1,29 @@
Sysinfo() {
Target=$([ -f /etc/openwrt_info ] && cat /etc/openwrt_info | awk 'NR==3')
Version=$([ -f /etc/openwrt_info ] && cat /etc/openwrt_info | awk 'NR==1' || Version=Unknown)
[ -z "${Target}" ] && Target=$(jsonfilter -e '@.model.id' < /etc/board.json | tr ',' '_')
IP_Address=$(ifconfig -a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | tr -d "addr:" | awk 'NR==1')
CoreMark=$([ -f /etc/bench.log ] && egrep -o "[0-9]+" /etc/bench.log | awk 'NR==1')
[ -z "${CoreMark}" ] && CoreMark=Unknown
Srartup=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d 天 %d 小时 %d 分钟\n",a,b,c)}' /proc/uptime)
Overlay_Available="$(df -h | grep ":/overlay" | awk '{print $4}' | awk 'NR==1')"
echo -e "\n\n 设备名称: ${Target}"
echo " 固件版本: ${Version}"
echo " IP 地址: ${IP_Address}"
echo " 运行时间: ${Srartup}"
echo " CoreMark: ${CoreMark}"
echo -e " 可用空间: ${Overlay_Available}\n"
}
[ -e /tmp/.failsafe ] && export FAILSAFE=1 [ -e /tmp/.failsafe ] && export FAILSAFE=1
clear clear
[ -f /etc/banner ] && cat /etc/banner [ -f /etc/banner ] && cat /etc/banner
[ -n "$FAILSAFE" ] && cat /etc/banner.failsafe [ -n "$FAILSAFE" ] && cat /etc/banner.failsafe
fgrep -sq '/ overlay ro,' /proc/mounts && { fgrep -sq '/ overlay ro,' /proc/mounts && {
echo '您的 JFFS2 分区似乎已满并且 overlayfs 挂载为只读.' echo "警告: 您的固件空间已满,接下来保存的数据将会面临丢失的风险."
echo '请尝试从 /overlay/upper/... 删除文件并重启!' echo "请尝试从 /overlay 删除一些文件并重启设备!"
} }
export PATH="/usr/sbin:/usr/bin:/sbin:/bin" export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
@ -28,18 +46,10 @@ esac
unset FILE unset FILE
} }
Target=$([ -f /etc/openwrt_info ] && cat /etc/openwrt_info | awk 'NR==3') Sysinfo
Version=$([ -f /etc/openwrt_info ] && cat /etc/openwrt_info | awk 'NR==1') alias autoupdate='bash /bin/AutoUpdate.sh'
[ -z "${Target}" ] && Target=$(jsonfilter -e '@.model.id' < /etc/board.json | tr ',' '_') alias AutoUpdate='bash /bin/AutoUpdate.sh'
IP_Address=$(ifconfig -a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | tr -d "addr:" | awk 'NR==1') alias Tools='bash /bin/AutoBuild*.sh'
CoreMark=$([ -f /etc/bench.log ] && egrep -o "[0-9]+" /etc/bench.log | awk 'NR==1') alias tools='bash /bin/AutoBuild*.sh'
[ -z "${CoreMark}" ] && CoreMark=0 alias coremarkd='bash /etc/coremark.sh'
Srartup=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d 天 %d 小时 %d 分钟\n",a,b,c)}' /proc/uptime) alias shutdown='sync && poweroff'
Overlay_Available="$(df -h | grep ":/overlay" | awk '{print $4}' | awk 'NR==1')"
echo -e "\n\n 设备名称: ${Target}"
echo " 固件版本: ${Version}"
echo " IP 地址: ${IP_Address}"
echo " 运行时间: ${Srartup}"
echo " CoreMark 得分: ${CoreMark}"
echo -e " 可用空间: ${Overlay_Available}\n"