Sysinfo() { TARGET_PROFILE=$(getinf TARGET_PROFILE /rom/etc/autoupdate/default) TARGET_BOARD=$(getinf TARGET_BOARD /rom/etc/autoupdate/default) [ -z "${TARGET_PROFILE}" ] && echo if [ "${TARGET_BOARD}" == x86 ] then [ -d /sys/firmware/efi ] && TARGET_BOOTABLE="UEFI" || TARGET_BOOTABLE="BIOS" fi [ -f /etc/bench.log ] && CoreMark=$(egrep -o "[0-9]+" /etc/bench.log | awk 'NR==1') if [ -n "$(sensors 2> /dev/null | grep Core)" ] then TEMP=$(echo "$(sensors 2> /dev/null | grep Core | awk '{Sum += $3};END {print Sum}') / $(sensors 2>/dev/null | grep Core | wc -l)" | bc 2> /dev/null) fi TEMP="$(temp_color ${TEMP})" if [ -n "${TARGET_BOOTABLE}" ] then printf " 设备信息: %-7s ${Div} ${Green}%-12s${White}\n" ${TARGET_PROFILE} ${TARGET_BOOTABLE} else [ -n "${TARGET_PROFILE}" ] && printf " 设备信息: ${TARGET_PROFILE}\n" fi printf " 内核版本: $(uname -rs | cut -d ' ' -f2)\n" printf " 可用内存: %-7s ${Div} %s of %s\n" $(free | grep Mem | awk '{a=$7*100/$2;b=$7/1024;c=$2/1024} {printf("%.1fM %.1f%% %.1fM",b,a,c)}') printf " 可用存储: %-7s ${Div} %s of %s\n" $(df -T '/' | grep -v File | awk '{a=$5*100/$3;b=$5/1024;c=$3/1024} {printf("%.1fM %.1f%% %.1fM",b,a,c)}') [ -n "${TEMP}" ] && printf " 设备温度: ${TEMP}\n" [ -n "${CoreMark}" ] && printf " 性能得分: ${CoreMark}\n" [ -f /proc/uptime ] && printf " 运行时间: $(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60;d=($1%60)} {printf("%d 天 %d 小时 %d 分钟 %d 秒\n",a,b,c,d)}' /proc/uptime)\n" [ -n "${SSH_CONNECTION}" ] && printf " 登录用户: %-7s ${Div} %s\n" ${LOGNAME} $(echo ${SSH_CONNECTION} | awk '{print $1":"$2}') printf "${White}\n" } getinf() { local i=$(grep $1 $2 2> /dev/null | awk 'END {print}') [ -z "${i}" ] && return 1 eval echo ${i} | sed "s/^[$1=]*//g" 2> /dev/null } temp_color() { if [ -n "$1" ] then if [ $1 -gt 55 ] then echo -ne "${Red}WARN ${1}°C${White}" else echo -n "${1}°C" fi fi } White="\e[0m" Yellow="\e[33m" Red="\e[31m" Blue="\e[34m" Grey="\e[36m" Green="\e[32m" Div="${Grey}|${White}" clear [ -e /tmp/.failsafe ] && export FAILSAFE=1 [ -f /etc/banner ] && printf "$(cat /etc/banner)\n" [ -n "$FAILSAFE" ] && cat /etc/banner.failsafe Sysinfo fgrep -sq '/ overlay ro,' /proc/mounts && { printf "${Red}警告: 固件可用空间已满,请尝试清理文件或重新刷写固件! 相反地,卸载系统自带软件包对空间清理没有任何帮助; 因此,请尝试卸载用户安装的软件包${White}\n\n" } 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 CONFIG=/etc/config if [ -n "${TARGET_PROFILE}" ] then export PS1='\u@\h[${TARGET_PROFILE}]:\w\$ ' else export PS1='\u@\h:\w\$ ' fi 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 } if ( grep -qs '^root::' /etc/shadow && \ [ -z "$FAILSAFE" ] ) then echo -e "${Red} ==================== 警告 ======================== 当前设备没有为 root 用户设置密码! 请使用 "passwd" 指令来设置一个系统密码来提高安全性 同时防止未经授权的 SSH 使用 root 非法登录 --------------------------------------------------${White} " fi alias reload='. /etc/profile' alias coremarkd='/etc/coremark.sh' alias shutdown='sync && poweroff' alias ls='ls --color=auto' alias l='ls -CF' alias ll='ls -alF' alias la='ls -A' alias cls='clear' alias dh='df -h' alias syslog='cat $(uci get system.@system[0].log_file) 2> /dev/null' alias ramfree='sync && echo 3 > /proc/sys/vm/drop_caches' alias top='top -d 1'