X-OpenWrt/CustomFiles/Depends/profile

90 lines
2.8 KiB
Plaintext
Raw Normal View History

Sysinfo() {
2021-06-06 05:54:41 +00:00
source /etc/AutoBuild/Default_Variable > /dev/null 2>&1
source /etc/AutoBuild/Custom_Variable > /dev/null 2>&1
[ -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 IP_Address=$(ifconfig -a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | tr -d "addr:" | awk 'NR==1')
local CoreMark=$([ -f /etc/bench.log ] && egrep -o "[0-9]+" /etc/bench.log | awk 'NR==1')
local Startup=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d 天 %d 小时 %d 分钟\n",a,b,c)}' /proc/uptime)
local Overlay_Available="$(df -h | grep ":/overlay" | awk '{print $4}' | awk 'NR==1')"
local TEMP=$(sensors 2>/dev/null | grep 'Core 0' | awk '{print $3}')
2021-06-06 05:54:41 +00:00
echo -e "\n 设备名称: ${Yellow}$(uname -n) / ${TARGET_PROFILE}${White}"
2021-05-11 14:14:58 +00:00
[ -n "${TEMP}" ] && echo " 核心温度: ${TEMP}"
echo " 内核版本: $(uname -rs)"
2021-06-06 05:54:41 +00:00
echo -e " 固件版本: ${Skyb}${CURRENT_Version}${White}"
echo " IP 地址 : ${IP_Address}"
echo " 可用空间: ${Overlay_Available}"
2021-05-11 14:14:58 +00:00
[ -n "${CoreMark}" ] && echo " 性能得分: ${CoreMark}"
echo " 运行时间: ${Startup}"
echo ""
}
2021-05-26 13:26:14 +00:00
export White="\e[0m"
export Yellow="\e[33m"
export Red="\e[31m"
export Blue="\e[34m"
export Skyb="\e[36m"
2021-05-11 14:14:58 +00:00
clear
[ -e /tmp/.failsafe ] && export FAILSAFE=1
[ -f /etc/banner ] && {
echo -e "$Skyb"
2021-05-11 14:14:58 +00:00
cat /etc/banner
echo -e "$White"
}
[ -n "$FAILSAFE" ] && {
echo -e "$Red"
cat /etc/banner.failsafe
echo -e "$White"
}
fgrep -sq '/ overlay ro,' /proc/mounts && {
2021-05-11 14:14:58 +00:00
echo -e "$Red"
echo "警告: 您的固件空间已满,接下来保存的数据将会面临丢失的风险."
echo "请尝试从 /overlay 删除一些文件并重启设备!"
2021-05-11 14:14:58 +00:00
echo -e "$White"
}
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
}
2021-05-15 08:10:57 +00:00
service() {
[ -f "/etc/init.d/$1" ] || {
echo -e "${Red}service "'"'"$1"'"'" not found, the following services are available:${White}\n"
2021-05-15 08:10:57 +00:00
ls "/etc/init.d"
return 1
}
/etc/init.d/$@
}
Sysinfo
alias reload='clear && /etc/profile'
alias autoupdate='bash /bin/AutoUpdate.sh'
alias tools='bash /bin/AutoBuild_Tools.sh'
alias run_coremark='bash /etc/coremark.sh'
alias shutdown='sync && poweroff'
2021-05-26 13:26:14 +00:00
alias ls='ls --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias cls='clear'
alias dh='df -h'
2021-06-06 05:54:41 +00:00
alias ramfree='sync && echo 3 > /proc/sys/vm/drop_caches'