2021-04-27 11:35:49 +00:00
|
|
|
Sysinfo() {
|
2021-08-24 15:57:53 +00:00
|
|
|
. /rom/etc/AutoBuild/Default_Variable 2>/dev/null
|
2021-06-06 05:54:41 +00:00
|
|
|
[ -z "${CURRENT_Version}" ] && CURRENT_Version=未知
|
|
|
|
[ -z "${TARGET_PROFILE}" ] && local TARGET_PROFILE=$(jsonfilter -e '@.model.id' < /etc/board.json | tr ',' '_')
|
2021-05-26 13:26:14 +00:00
|
|
|
local CoreMark=$([ -f /etc/bench.log ] && egrep -o "[0-9]+" /etc/bench.log | awk 'NR==1')
|
2021-06-28 14:09:01 +00:00
|
|
|
local Startup=$(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)
|
2021-08-12 05:17:27 +00:00
|
|
|
[ -n "$(sensors 2> /dev/null | grep Core)" ] && local 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 | awk '{a=$1;b=32+$1*1.8} {printf("%d°C \e[36m|\e[0m %.1f°F\n",a,b)}')
|
2021-08-24 15:57:53 +00:00
|
|
|
echo -e " 设备信息: ${Yellow}${TARGET_PROFILE}${White}"
|
|
|
|
echo -e " 内核版本: $(uname -rs)"
|
2021-08-10 17:20:52 +00:00
|
|
|
echo -e " 可用内存: $(free | grep Mem | awk '{a=$7*100/$2;b=$7/1024;c=$2/1024} {printf("%.1fM \e[36m|\e[0m %.1f%% of %.1fM\n",b,a,c)}')"
|
|
|
|
echo -e " 可用存储: $(df -T / | grep 'overlay' | awk '{a=$5*100/$3;b=$5/1024;c=$3/1024} {printf("%.1fM \e[36m|\e[0m %.1f%% of %.1fM\n",b,a,c)}')"
|
2021-08-05 07:27:21 +00:00
|
|
|
[ -n "${TEMP}" ] && echo -e " 设备温度: ${TEMP}"
|
|
|
|
[ -n "${CoreMark}" ] && echo -e " 性能得分: ${CoreMark} Scores"
|
|
|
|
echo -e " 运行时间: ${Startup}"
|
2021-08-24 15:57:53 +00:00
|
|
|
[ -n "${SSH_CONNECTION}" ] && echo -e " 登录用户: ${LOGNAME} ${Div} ${Grey}$(echo ${SSH_CONNECTION} | awk '{print $1":"$2}')"
|
|
|
|
echo -e "${White}"
|
2021-04-27 11:35:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-24 15:57:53 +00:00
|
|
|
White="\e[0m"
|
|
|
|
Yellow="\e[33m"
|
|
|
|
Red="\e[31m"
|
|
|
|
Blue="\e[34m"
|
|
|
|
Grey="\e[36m"
|
|
|
|
Green="\e[32m"
|
2021-08-05 07:27:21 +00:00
|
|
|
Div="${Grey}|${White}"
|
2021-03-27 16:25:29 +00:00
|
|
|
|
2021-06-18 13:52:28 +00:00
|
|
|
clear
|
2021-06-17 15:43:35 +00:00
|
|
|
|
2021-06-18 13:52:28 +00:00
|
|
|
[ -e /tmp/.failsafe ] && export FAILSAFE=1
|
2021-08-24 15:57:53 +00:00
|
|
|
[ -f /etc/banner ] && echo -e "$(cat /etc/banner)"
|
2021-06-17 15:43:35 +00:00
|
|
|
[ -n "$FAILSAFE" ] && cat /etc/banner.failsafe
|
|
|
|
|
2021-08-24 15:57:53 +00:00
|
|
|
Sysinfo
|
|
|
|
|
2021-03-27 16:25:29 +00:00
|
|
|
fgrep -sq '/ overlay ro,' /proc/mounts && {
|
2021-08-24 15:57:53 +00:00
|
|
|
echo -e "${Red} 警告: 固件空间可能已满,请尝试从 /overlay 中删除一些文件然后重启设备!${White}\n"
|
2021-03-27 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 13:52:28 +00:00
|
|
|
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
2021-03-27 16:25:29 +00:00
|
|
|
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" ] || {
|
2021-06-17 15:43:35 +00:00
|
|
|
for FILE in /etc/profile.d/*.sh; do
|
2021-03-27 16:25:29 +00:00
|
|
|
[ -e "$FILE" ] && . "$FILE"
|
|
|
|
done
|
|
|
|
unset FILE
|
|
|
|
}
|
|
|
|
|
2021-06-17 15:43:35 +00:00
|
|
|
if ( grep -qs '^root::' /etc/shadow && \
|
|
|
|
[ -z "$FAILSAFE" ] )
|
|
|
|
then
|
2021-08-24 15:57:53 +00:00
|
|
|
echo -e "${Red} ==================== 警告 ========================
|
|
|
|
当前设备没有为 root 用户设置密码!
|
|
|
|
请使用 "passwd" 指令来设置一个系统密码来提高安全性
|
|
|
|
同时防止未经授权的 SSH 使用 root 非法登录
|
|
|
|
--------------------------------------------------${White}
|
|
|
|
"
|
2021-06-17 15:43:35 +00:00
|
|
|
fi
|
2021-05-15 08:10:57 +00:00
|
|
|
|
2021-06-18 13:52:28 +00:00
|
|
|
alias reload='/etc/profile'
|
2021-04-27 11:35:49 +00:00
|
|
|
alias autoupdate='bash /bin/AutoUpdate.sh'
|
2021-05-15 08:43:25 +00:00
|
|
|
alias tools='bash /bin/AutoBuild_Tools.sh'
|
2021-08-05 07:27:21 +00:00
|
|
|
alias coremarkd='bash /etc/coremark.sh'
|
2021-05-15 08:43:25 +00:00
|
|
|
alias shutdown='sync && poweroff'
|
2021-05-26 13:26:14 +00:00
|
|
|
alias ls='ls --color=auto'
|
2021-08-24 15:57:53 +00:00
|
|
|
alias l='ls -CF'
|
2021-05-26 13:26:14 +00:00
|
|
|
alias ll='ls -alF'
|
|
|
|
alias la='ls -A'
|
|
|
|
alias cls='clear'
|
|
|
|
alias dh='df -h'
|
2021-08-05 07:27:21 +00:00
|
|
|
alias ramfree='sync && echo 3 > /proc/sys/vm/drop_caches'
|