X-OpenWrt/CustomFiles/Depends/profile

60 lines
2.0 KiB
Plaintext
Raw Normal View History

Sysinfo() {
2021-05-06 14:56:59 +00:00
[ -f /etc/openwrt_info ] && {
source /etc/openwrt_info
Target=${DEFAULT_Device}
}
[[ -n "${CURRENT_Version}" ]] && Version="${CURRENT_Version}" || 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')
2021-05-06 14:56:59 +00:00
[[ -z "${CoreMark}" ]] && CoreMark=Unknown
Startup=$(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"
echo " 设备名称: $(uname -n) / ${Target}"
echo " 固件版本: ${Version}"
echo " 内核版本: $(uname -rs)"
echo " IP 地址 : ${IP_Address}"
echo " 运行时间: ${Startup}"
echo " 性能得分: ${CoreMark}"
echo " 可用空间: ${Overlay_Available}"
echo ""
}
[ -e /tmp/.failsafe ] && export FAILSAFE=1
clear
[ -f /etc/banner ] && cat /etc/banner
[ -n "$FAILSAFE" ] && cat /etc/banner.failsafe
fgrep -sq '/ overlay ro,' /proc/mounts && {
echo "警告: 您的固件空间已满,接下来保存的数据将会面临丢失的风险."
echo "请尝试从 /overlay 删除一些文件并重启设备!"
}
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
export HOME=${HOME:-/root}
export PS1='\u@\h:\w\$ '
export ENV=/etc/shinit
case "$TERM" in
xterm*|rxvt*)
export PS1='\[\e]0;\u@\h: \w\a\]'$PS1
;;
esac
[ -n "$FAILSAFE" ] || {
for FILE in /etc/profile.d/*.sh
do
[ -e "$FILE" ] && . "$FILE"
done
unset FILE
}
Sysinfo
alias autoupdate='bash /bin/AutoUpdate.sh'
alias AutoUpdate='bash /bin/AutoUpdate.sh'
alias Tools='bash /bin/AutoBuild*.sh'
alias tools='bash /bin/AutoBuild*.sh'
alias coremarkd='bash /etc/coremark.sh'
2021-05-06 14:56:59 +00:00
alias shutdown='sync && poweroff'