优化代码

This commit is contained in:
Hyy2001X 2021-05-12 21:15:10 +08:00
parent 8aab05fa5c
commit dd1a4b3923
3 changed files with 23 additions and 22 deletions

View File

@ -1,5 +1,5 @@
Sysinfo() {
[ -f /etc/openwrt_info ] && source /etc/openwrt_info
[ -f /etc/openwrt_info ] && source /etc/openwrt_info > /dev/null 2>&1
export Target=${DEFAULT_Device}
[ -n "${CURRENT_Version}" ] && export Version="${CURRENT_Version}" || Version=Unknown
[ -z "${Target}" ] && export Target=$(jsonfilter -e '@.model.id' < /etc/board.json | tr ',' '_')
@ -8,8 +8,7 @@ Sysinfo() {
export Startup=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d 天 %d 小时 %d 分钟\n",a,b,c)}' /proc/uptime)
export Overlay_Available="$(df -h | grep ":/overlay" | awk '{print $4}' | awk 'NR==1')"
export TEMP=$(sensors 2>/dev/null | grep 'Core 0' | awk '{print $3}')
echo -e "\n"
echo -e " 设备名称: ${Yellow}$(uname -n) / ${Target}${White}"
echo -e "\n 设备名称: ${Yellow}$(uname -n) / ${Target}${White}"
[ -n "${TEMP}" ] && echo " 核心温度: ${TEMP}"
echo " 内核版本: $(uname -rs)"
echo -e " 固件版本: ${Skyb}${Version}${White}"
@ -20,11 +19,11 @@ Sysinfo() {
echo ""
}
export White="\e[0m"
export Yellow="\e[33m"
export Red="\e[31m"
export Blue="\e[34m"
export Skyb="\e[36m"
White="\e[0m"
Yellow="\e[33m"
Red="\e[31m"
Blue="\e[34m"
Skyb="\e[36m"
clear
[ -e /tmp/.failsafe ] && export FAILSAFE=1

View File

@ -8,11 +8,11 @@ GET_TARGET_INFO() {
Home="${GITHUB_WORKSPACE}/openwrt"
[ -f "${GITHUB_WORKSPACE}/Openwrt.info" ] && . ${GITHUB_WORKSPACE}/Openwrt.info
[[ "${Short_Firmware_Date}" == true ]] && Compile_Date="$(echo ${Compile_Date} | cut -c1-8)"
User_Repo="$(grep "https://github.com/[a-zA-Z0-9]" ${GITHUB_WORKSPACE}/.git/config | cut -c8-100)"
User_Repo="$(grep "https://github.com/[a-zA-Z0-9]" ${GITHUB_WORKSPACE}/.git/config | cut -c8-100 | sed 's/^[ \t]*//g')"
[[ -z "${Author}" ]] && {
Author="$(echo "${User_Repo}" | egrep -o "[a-zA-Z0-9]+" | awk 'NR==4')"
}
Openwrt_Repo="$(grep "https://github.com/[a-zA-Z0-9]" ${Home}/.git/config | cut -c8-100)"
Openwrt_Repo="$(grep "https://github.com/[a-zA-Z0-9]" ${Home}/.git/config | cut -c8-100 | sed 's/^[ \t]*//g')"
Openwrt_Author="$(echo "${Openwrt_Repo}" | egrep -o "[a-zA-Z0-9]+" | awk 'NR==4')"
Current_Branch="$(git branch | sed 's/* //g' | sed 's/^[ \t]*//g')"
In_Firmware_Info=package/base-files/files/etc/openwrt_info
@ -75,9 +75,9 @@ GET_TARGET_INFO() {
echo "TARGET_SUBTARGET=${TARGET_SUBTARGET}" >> ${Home}/TARGET_INFO
echo "Home=${Home}" >> ${Home}/TARGET_INFO
echo "Current_Branch=${Current_Branch}" >> ${Home}/TARGET_INFO
echo "CURRENT_Version=${Openwrt_Version}" > ${In_Firmware_Info}
echo "Github=${User_Repo}" >> ${In_Firmware_Info}
echo "Github=${User_Repo}" > ${In_Firmware_Info}
echo "CURRENT_Version=${Openwrt_Version}" >> ${In_Firmware_Info}
echo "DEFAULT_Device=${TARGET_PROFILE}" >> ${In_Firmware_Info}
echo "Firmware_Type=${Firmware_Type}" >> ${In_Firmware_Info}

View File

@ -3,7 +3,7 @@
# AutoBuild Module by Hyy2001
# AutoUpdate for Openwrt
Version=V5.7.2
Version=V5.7.3
Shell_Helper() {
cat <<EOF
@ -237,15 +237,17 @@ else
;;
esac
fi
if [[ "$(cat /tmp/Package_list)" =~ "curl" ]];then
Google_Check=$(curl -I -s --connect-timeout 3 google.com -w %{http_code} | tail -n1)
[[ ! "$Google_Check" == 301 ]] && {
TIME && echo "Google 连接失败,尝试使用 [FastGit] 镜像加速!"
if [ -z "${PROXY_Release}" ];then
if [[ "$(cat /tmp/Package_list)" =~ "curl" ]];then
Google_Check=$(curl -I -s --connect-timeout 3 google.com -w %{http_code} | tail -n1)
[[ ! "$Google_Check" == 301 ]] && {
TIME && echo "Google 连接失败,尝试使用 [FastGit] 镜像加速!"
PROXY_Release="${_PROXY_Release}"
}
else
TIME && echo "无法确定网络环境,默认开启 [FastGit] 镜像加速!"
PROXY_Release="${_PROXY_Release}"
}
else
TIME && echo "无法确定网络环境,默认使用 [FastGit] 镜像加速!"
PROXY_Release="${_PROXY_Release}"
fi
fi
[[ "${TMP_Available}" -lt "${Space_Min}" ]] && {
TIME && echo "/tmp 空间不足: [${Space_Min}M],无法执行更新!"