mirror of
https://github.com/roacn/openwrt-packages.git
synced 2025-01-07 03:16:45 +08:00
🏅 Sync 2023-11-04 15:52
This commit is contained in:
parent
18a03885be
commit
963831c591
@ -1,10 +1,10 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI Support for AutoBuild Firmware/AutoUpdate.sh
|
||||
LUCI_DEPENDS:=+curl +wget +bash
|
||||
LUCI_TITLE:=LuCI Support for AutoBuild Firmware/AutoUpdate
|
||||
LUCI_DEPENDS:=+curl +wget +wget-ssl
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=20210221
|
||||
PKG_RELEASE:=20221121
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
1
luci-app-autoupdate/README.md
Normal file
1
luci-app-autoupdate/README.md
Normal file
@ -0,0 +1 @@
|
||||
匹配[build-actions](https://github.com/roacn/build-actions)固件使用!
|
@ -3,8 +3,9 @@ require("luci.sys")
|
||||
m=Map("autoupdate",translate("AutoUpdate"),translate("AutoUpdate LUCI supports one-click firmware upgrade and scheduled upgrade"))
|
||||
|
||||
s=m:section(TypedSection,"login","")
|
||||
s.addremove=false
|
||||
s.anonymous=true
|
||||
s.addremove=false
|
||||
|
||||
|
||||
o = s:option(Flag, "enable", translate("Enable AutoUpdate"),translate("Automatically update firmware during the specified time"))
|
||||
o.default = 0
|
||||
@ -29,22 +30,23 @@ pass=s:option(Value,"minute",translate("xMinute"))
|
||||
pass.datatype = "range(0,59)"
|
||||
pass.rmempty = false
|
||||
|
||||
local github_url = luci.sys.exec("grep Github= /bin/openwrt_info | cut -c8-100")
|
||||
local github_url = luci.sys.exec("grep -i GITHUB_REPOSITORY_URL= /etc/openwrt_autoupdate | sed 's/\"//g'| awk -F '=' '{print $2;}'")
|
||||
o=s:option(Value,"github",translate("Github Url"))
|
||||
o.default=github_url
|
||||
|
||||
luci.sys.call ( "/usr/share/autoupdate/Check_Update.sh > /dev/null")
|
||||
local cloud_version = luci.sys.exec("cat /tmp/cloud_version")
|
||||
local current_version = luci.sys.exec("grep CURRENT_Version= /etc/openwrt_ver | cut -c17-100")
|
||||
local current_model = luci.sys.exec("jsonfilter -e '@.model.id' < /etc/board.json | tr ',' '_'")
|
||||
local firmware_type = luci.sys.exec("grep CURRENT_Model= /etc/openwrt_ver | cut -c15-100")
|
||||
local luci_edition = luci.sys.exec("grep NEI_Luci= /etc/openwrt_ver | cut -c10-100")
|
||||
luci.sys.call("autoupdate -c > /dev/null")
|
||||
|
||||
button_upgrade_firmware = s:option (Button, "_button_upgrade_firmware", translate("Upgrade to Latested Version"),
|
||||
translatef("若有更新可点击上方 手动更新 后请耐心等待至路由器重启.") .. "<br><br>当前固件版本: " .. current_version .. "<br>云端固件版本: " .. cloud_version.. "<br><br>设备名称: " .. current_model .. "<br>内核版本: " .. luci_edition .. "<br>固件类型: " .. firmware_type)
|
||||
local cloud_version = luci.sys.exec("cat /tmp/autoupdate/autoupdate.cloud")
|
||||
local current_version = luci.sys.exec("grep -i CURRENT_FIRMWARE= /etc/openwrt_autoupdate | sed 's/\"//g'| awk -F '=' '{print $2;}'")
|
||||
local cpu_info = luci.sys.exec("grep -i CPU_INFO= /tmp/autoupdate/autoupdate.info | sed 's/\"//g'| awk -F '=' '{print $2;}'")
|
||||
local kernel_luci = luci.sys.exec("grep -i KERNEL_LUCI= /tmp/autoupdate/autoupdate.info | sed 's/\"//g'| awk -F '=' '{print $2;}'")
|
||||
local firmware_type = luci.sys.exec("grep -i FIRMWARE_TYPE= /tmp/autoupdate/autoupdate.info | sed 's/\"//g'| awk -F '=' '{print $2;}'")
|
||||
|
||||
button_upgrade_firmware = s:option(Button, "_button_upgrade_firmware", translate("Upgrade to Latested Version"),
|
||||
translatef("若有更新可点击上方 手动更新 后请耐心等待至路由器重启.") .. "<br><br>当前固件版本: " .. current_version .. "<br>云端固件版本: " .. cloud_version.. "<br><br>设备名称: " .. cpu_info .. "<br>内核版本: " .. kernel_luci .. "<br>固件类型: " .. firmware_type)
|
||||
button_upgrade_firmware.inputtitle = translate ("Do Upgrade")
|
||||
button_upgrade_firmware.write = function()
|
||||
luci.sys.call ("bash /bin/AutoUpdate.sh -u > /dev/null")
|
||||
luci.sys.call ("autoupdate -u > /dev/null")
|
||||
end
|
||||
|
||||
local e=luci.http.formvalue("cbi.apply")
|
||||
|
@ -1,5 +1,15 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: zh-cn\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "AutoUpdate"
|
||||
msgstr "定时更新"
|
||||
msgstr "在线更新"
|
||||
|
||||
msgid "xWeek Day"
|
||||
msgstr "更新时间"
|
||||
@ -23,7 +33,7 @@ msgid "Enable AutoUpdate"
|
||||
msgstr "启用定时更新"
|
||||
|
||||
msgid "AutoUpdate LUCI supports one-click firmware upgrade and scheduled upgrade"
|
||||
msgstr "定时更新 LUCI 支持手动更新以及定时更新固件"
|
||||
msgstr "定时更新LUCI,也可以SSH连接OpenWrt或OpenWrt内使用TTYD输入autoupdate命令进行命令在线更新"
|
||||
|
||||
msgid "Do Upgrade"
|
||||
msgstr "手动更新"
|
||||
@ -39,3 +49,6 @@ msgstr "Github 地址"
|
||||
|
||||
msgid "Please wait patiently after clicking Do Upgrade button"
|
||||
msgstr "点击手动更新按钮后请耐心等待至路由器重启"
|
||||
|
||||
msgid "If there is an update, click above to manually update. Please wait patiently until the router restarts"
|
||||
msgstr "若有更新可点击上方 手动更新 后请耐心等待至路由器重启"
|
||||
|
@ -1 +0,0 @@
|
||||
zh-cn
|
54
luci-app-autoupdate/po/zh_Hans/autoupdate.po
Normal file
54
luci-app-autoupdate/po/zh_Hans/autoupdate.po
Normal file
@ -0,0 +1,54 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: zh_Hans\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "AutoUpdate"
|
||||
msgstr "在线更新"
|
||||
|
||||
msgid "xWeek Day"
|
||||
msgstr "更新时间"
|
||||
|
||||
msgid "Everyday"
|
||||
msgstr "每天"
|
||||
|
||||
msgid "Day"
|
||||
msgstr "天"
|
||||
|
||||
msgid "xHour"
|
||||
msgstr "时 [0~23]"
|
||||
|
||||
msgid "xMinute"
|
||||
msgstr "分 [0~59]"
|
||||
|
||||
msgid "Check Update"
|
||||
msgstr "检查更新"
|
||||
|
||||
msgid "Enable AutoUpdate"
|
||||
msgstr "启用定时更新"
|
||||
|
||||
msgid "AutoUpdate LUCI supports one-click firmware upgrade and scheduled upgrade"
|
||||
msgstr "定时更新LUCI,也可以SSH连接OpenWrt或OpenWrt内使用TTYD输入autoupdate命令进行命令在线更新"
|
||||
|
||||
msgid "Do Upgrade"
|
||||
msgstr "手动更新"
|
||||
|
||||
msgid "Upgrade to Latested Version"
|
||||
msgstr "更新固件"
|
||||
|
||||
msgid "Automatically update firmware during the specified time"
|
||||
msgstr "在指定时间段自动检测云端版本,若有新版本自动更新固件"
|
||||
|
||||
msgid "Github Url"
|
||||
msgstr "Github 地址"
|
||||
|
||||
msgid "Please wait patiently after clicking Do Upgrade button"
|
||||
msgstr "点击手动更新按钮后请耐心等待至路由器重启"
|
||||
|
||||
msgid "If there is an update, click above to manually update. Please wait patiently until the router restarts"
|
||||
msgstr "若有更新可点击上方 手动更新 后请耐心等待至路由器重启"
|
54
luci-app-autoupdate/root/etc/init.d/autoupdate
Normal file → Executable file
54
luci-app-autoupdate/root/etc/init.d/autoupdate
Normal file → Executable file
@ -1,32 +1,35 @@
|
||||
#!/bin/bash /etc/rc.common
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=99
|
||||
|
||||
run_autoupdate()
|
||||
{
|
||||
local enable
|
||||
config_get_bool enable $1 enable
|
||||
if [ $enable == "1" ]; then
|
||||
local minute
|
||||
local hour
|
||||
config_get week $1 week
|
||||
config_get minute $1 minute
|
||||
config_get hour $1 hour
|
||||
[ "$week" == 7 ] && week="*"
|
||||
sed -i '/AutoUpdate/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
echo "$minute $hour * * $week bash /bin/AutoUpdate.sh -u" >> /etc/crontabs/root
|
||||
else
|
||||
sed -i '/AutoUpdate/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
if [[ -f "/usr/bin/autoupdate" ]] && [[ -f "/etc/openwrt_autoupdate" ]]; then
|
||||
local enable
|
||||
config_get_bool enable $1 enable
|
||||
if [ $enable == "1" ]; then
|
||||
local minute
|
||||
local hour
|
||||
config_get week $1 week
|
||||
config_get minute $1 minute
|
||||
config_get hour $1 hour
|
||||
[ "$week" == 7 ] && week="*"
|
||||
sed -i '/autoupdate/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
echo "$minute $hour * * $week autoupdate -u" >> /etc/crontabs/root
|
||||
/etc/init.d/cron restart
|
||||
else
|
||||
stop
|
||||
fi
|
||||
cus_url="$(uci get autoupdate.@login[0].github)"
|
||||
if [[ "$(echo "${cus_url}" |head -n 5 |cut -d '/' -f 1-3)" == 'https://github.com' ]]; then
|
||||
custom_github_repository="$(echo "${cus_url}" |head -n 5 |cut -d '/' -f 4-5)"
|
||||
current_github_repository="$(grep GITHUB_REPOSITORY_URL= /etc/openwrt_autoupdate |head -n 5 |cut -d '/' -f 4-5)"
|
||||
fi
|
||||
if [[ `echo "${custom_github_repository}" |grep -c '/'` -eq '1' ]] && [[ "${custom_github_repository}" != "${current_github_repository}" ]]; then
|
||||
sed -i "s?${current_github_repository}?${custom_github_repository}?g" /etc/openwrt_autoupdate
|
||||
uci set autoupdate.@login[0].github=${cus_url}
|
||||
uci commit autoupdate
|
||||
fi
|
||||
fi
|
||||
if [ -f /bin/AutoUpdate.sh ] && [ -f /bin/openwrt_info ];then
|
||||
custom_github_url="$(uci get autoupdate.@login[0].github)"
|
||||
current_github_url="$(grep Github= /bin/openwrt_info | cut -c8-100)"
|
||||
[[ -n "${custom_github_url}" ]] && {
|
||||
[[ "${custom_github_url}" != "${current_github_url}" ]] && {
|
||||
sed -i "s?${current_github_url}?${custom_github_url}?g" /bin/openwrt_info
|
||||
}
|
||||
}
|
||||
fi
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +41,8 @@ start()
|
||||
|
||||
stop()
|
||||
{
|
||||
sed -i '/AutoUpdate/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
sed -i '/autoupdte/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
|
||||
restart()
|
||||
|
312
luci-app-autoupdate/root/usr/bin/autoupdate
Executable file
312
luci-app-autoupdate/root/usr/bin/autoupdate
Executable file
@ -0,0 +1,312 @@
|
||||
#!/bin/sh
|
||||
# AutoUpdate for Openwrt
|
||||
|
||||
Version=V8.1
|
||||
|
||||
# 设置
|
||||
INPUT_OPTION=$1
|
||||
# 路径
|
||||
TMP_AUTOUPDATE_PATH=/tmp/autoupdate
|
||||
DOWNLOAD_PATH=${TMP_AUTOUPDATE_PATH}/download
|
||||
# 文件
|
||||
OPENWRT_AUTOUPDATE=/etc/openwrt_autoupdate
|
||||
AUTOUPDATE_LOG=${TMP_AUTOUPDATE_PATH}/autoupdate.log
|
||||
AUTOUPDATE_INFO=${TMP_AUTOUPDATE_PATH}/autoupdate.info
|
||||
AUTOUPDATE_CLOUD=${TMP_AUTOUPDATE_PATH}/autoupdate.cloud
|
||||
|
||||
function ping_test() {
|
||||
ping $1 -c 1 -W $2 > /dev/null 2>&1
|
||||
[[ $? == 0 ]] && echo true || echo false
|
||||
}
|
||||
|
||||
function network_check() {
|
||||
[[ $(ping_test 223.5.5.5 2) == false ]] && {
|
||||
echo "网络连接错误!"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 网络连接错误!" >> ${AUTOUPDATE_LOG}
|
||||
exit 1
|
||||
} || {
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 网络连接正常." >> ${AUTOUPDATE_LOG}
|
||||
}
|
||||
}
|
||||
|
||||
function firmware_info() {
|
||||
source ${OPENWRT_AUTOUPDATE}
|
||||
|
||||
[[ ! -d ${DOWNLOAD_PATH} ]] && mkdir -p ${DOWNLOAD_PATH} || rm -rf ${DOWNLOAD_PATH}/*
|
||||
|
||||
# 下载api文件
|
||||
echo "开始获取API数据..."
|
||||
wget -q --no-check-certificate ${GITHUB_API_URL_GHPROXY} -O ${DOWNLOAD_PATH}/${GITHUB_API}
|
||||
if [[ ! -s ${DOWNLOAD_PATH}/${GITHUB_API} ]]; then
|
||||
curl -fsSL ${GITHUB_API_URL_FASTGIT} -o ${DOWNLOAD_PATH}/${GITHUB_API}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
curl -fsSL ${GITHUB_API_URL_ORIGIN} -o ${DOWNLOAD_PATH}/${GITHUB_API}
|
||||
fi
|
||||
fi
|
||||
if [[ -s "${DOWNLOAD_PATH}/${GITHUB_API}" ]]; then
|
||||
echo "获取API数据成功."
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 获取API数据成功." >> ${AUTOUPDATE_LOG}
|
||||
else
|
||||
echo "获取API数据失败,Github地址不正确,或此地址没云端存在,或您的仓库为私库!"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 获取API数据失败,Github地址不正确,或此地址没云端存在,或您的仓库为私库" >> ${AUTOUPDATE_LOG}
|
||||
echo "获取API数据失败,Github地址不正确,或此地址没云端存在,或您的仓库为私库!" > ${AUTOUPDATE_CLOUD}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 固件格式、CPU信息
|
||||
case "${TARGET_BOARD}" in
|
||||
x86)
|
||||
# 固件格式,如:uefi,或legacy
|
||||
[ -d '/sys/firmware/efi' ] && {
|
||||
BOOT_TYPE=uefi
|
||||
} || {
|
||||
BOOT_TYPE=legacy
|
||||
}
|
||||
# CPU信息,如:Intel(R) Celeron(R) J4125 @ 2.00GHz
|
||||
CPU_INFO=$(cat /proc/cpuinfo |grep 'model name' |awk 'END {print}' |cut -f2 -d: |sed 's/^[ ]*//g'|sed 's/\ CPU//g')
|
||||
[[ -z "${CPU_INFO}" ]] && CPU_INFO="${TARGET_PROFILE}"
|
||||
;;
|
||||
*)
|
||||
# CPU信息,如:qemu-standard-pc-q35-ich9-2009
|
||||
CPU_INFO=$(jsonfilter -e '@.model.id' < /etc/board.json | tr ',' '_')
|
||||
# 固件格式,如:sysupgrade
|
||||
BOOT_TYPE=sysupgrade
|
||||
esac
|
||||
|
||||
# Openwrt内核版本
|
||||
local kernel_patchver=$(uname -rs | awk '{print $2;}')
|
||||
|
||||
# 本地固件信息
|
||||
# lede-18.06-x86-64-202310100000
|
||||
LOCAL_FIRMWARE=${CURRENT_FIRMWARE}
|
||||
# 202310100000
|
||||
LOCAL_COMPILE_DATE=${COMPILE_DATE}
|
||||
|
||||
|
||||
# 云端固件信息
|
||||
local firmware_list_m="${DOWNLOAD_PATH}/firmware_list_m"
|
||||
local firmware_list_s="${DOWNLOAD_PATH}/firmware_list_s"
|
||||
# lede-18.06-x86-64-202310062251-uefi-bc5ccc.img.gz
|
||||
FIRMWARE_LIST_M=$(grep -E "\"name\"" ${DOWNLOAD_PATH}/${GITHUB_API} | grep -i -Eo ".*${TARGET_PROFILE}.*${FIRMWARE_EXT}" | grep -i -E "${BOOT_TYPE}" | sed "s/ //g" | sed "s/\"//g" | awk -F ':' '{print $2;}' | sort -r)
|
||||
FIRMWARE_LIST_S=$(echo "${FIRMWARE_LIST_M}" | grep -i -E "${SOURCE}" | grep -i -E "${LUCI_EDITION}")
|
||||
echo "${FIRMWARE_LIST_M}" > ${firmware_list_m}
|
||||
echo "${FIRMWARE_LIST_S}" > ${firmware_list_s}
|
||||
|
||||
case ${INPUT_OPTION} in
|
||||
-c|-u|-s)
|
||||
CLOUD_FIRMWARE_FILENAME=$(cat ${firmware_list_s} | head -n 1 | tail -n 1)
|
||||
;;
|
||||
-m)
|
||||
echo "云端固件:"
|
||||
awk '{print " " NR ". " $0}' ${firmware_list_m}
|
||||
local rows=$(cat ${firmware_list_m} | wc -l)
|
||||
while :; do
|
||||
read -p "请输入要选择的OpenWrt固件[默认1]:" num || echo
|
||||
num=${num:-1}
|
||||
local tmp_num=`echo ${num} | sed 's/[0-9]//g'`
|
||||
if [[ ! -z ${tmp_num} ]]; then
|
||||
echo "请输入数字,请重新输入!"
|
||||
elif [[ ${num} -gt ${rows} ]]; then
|
||||
echo "当前输入值超过可选范围,请重新输入!"
|
||||
else
|
||||
CLOUD_FIRMWARE_FILENAME=$(cat ${firmware_list_m} | head -n ${num} | tail -n 1)
|
||||
echo "[已选] ${CLOUD_FIRMWARE_FILENAME}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
# 202310101000
|
||||
CLOUD_COMPILE_DATE=$(echo "${CLOUD_FIRMWARE_FILENAME}" | sed "s/.*${TARGET_PROFILE}//g" | sed "s/${BOOT_TYPE}.*//g" | grep -Eo [0-9]+)
|
||||
CLOUD_FIRMWARE=$(echo ${CLOUD_FIRMWARE_FILENAME} | sed "s/\(.*\)-${BOOT_TYPE}.*/\1/")
|
||||
if [[ -n "${CLOUD_FIRMWARE_FILENAME}" ]] && [[ -n "${CLOUD_COMPILE_DATE}" ]] && [[ -n "${CLOUD_FIRMWARE}" ]]; then
|
||||
echo "获取云端信息成功."
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 获取云端信息成功." >> ${AUTOUPDATE_LOG}
|
||||
else
|
||||
echo "获取云端信息失败,x86注意本地跟云端固件显示的引导模式是否一致,或者就是云端压根就没您同类型的固件存在,或者作者更了固件获取条件导致您本地跟云端信息不一致!"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 获取云端信息失败,x86注意本地跟云端固件显示的引导模式是否一致,或者就是云端压根就没您同类型的固件存在,或者作者更了固件获取条件导致您本地跟云端信息不一致!" >> ${AUTOUPDATE_LOG}
|
||||
echo "获取云端信息失败,x86注意本地跟云端固件显示的引导模式是否一致,或者就是云端压根就没您同类型的固件存在,或者作者更了固件获取条件导致您本地跟云端信息不一致!" > ${AUTOUPDATE_CLOUD}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
cat > ${AUTOUPDATE_INFO} <<-EOF
|
||||
LOCAL_COMPILE_DATE=${LOCAL_COMPILE_DATE}
|
||||
CLOUD_COMPILE_DATE=${CLOUD_COMPILE_DATE}
|
||||
LOCAL_FIRMWARE=${LOCAL_FIRMWARE}
|
||||
CLOUD_FIRMWARE=${CLOUD_FIRMWARE}
|
||||
CPU_INFO=${CPU_INFO}
|
||||
KERNEL_LUCI=${kernel_patchver}-${LUCI_EDITION}
|
||||
FIRMWARE_TYPE=${BOOT_TYPE}${FIRMWARE_EXT}
|
||||
EOF
|
||||
|
||||
echo "信息检测完毕."
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 信息检测完毕." >> ${AUTOUPDATE_LOG}
|
||||
}
|
||||
|
||||
function firmware_check() {
|
||||
network_check
|
||||
firmware_info
|
||||
if [[ "${LOCAL_COMPILE_DATE}" -eq "${CLOUD_COMPILE_DATE}" ]]; then
|
||||
local checked_type="已是最新"
|
||||
elif [[ "${LOCAL_COMPILE_DATE}" -lt "${CLOUD_COMPILE_DATE}" ]]; then
|
||||
local checked_type="有可更新固件"
|
||||
elif [[ "${LOCAL_COMPILE_DATE}" -gt "${CLOUD_COMPILE_DATE}" ]]; then
|
||||
local checked_type="云端最高版本固件,低于您现在所使用版本,请到云端查看原因"
|
||||
fi
|
||||
echo "${CLOUD_FIRMWARE} [${checked_type}]"
|
||||
echo "${CLOUD_FIRMWARE} [${checked_type}]" > ${AUTOUPDATE_CLOUD}
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
function firmware_upgrade() {
|
||||
network_check
|
||||
firmware_info
|
||||
# tmp文件夹可用空间(单位:MB)
|
||||
local tmp_available=$(df -m | grep -i "/tmp" | awk '{print $4}' | awk 'NR==1' | awk -F. '{print $1}')
|
||||
let X=$(grep -i -n "${CLOUD_FIRMWARE_FILENAME}" ${DOWNLOAD_PATH}/${GITHUB_API} | tail -1 | cut -d : -f 1)-4
|
||||
let cloud_firmware_size=$(sed -n "${X}p" ${DOWNLOAD_PATH}/${GITHUB_API} | grep -Eo "[0-9]+" | awk '{print ($1)/1048576}' | awk -F. '{print $1}')+1
|
||||
if [[ "${tmp_available}" -lt "${cloud_firmware_size}" ]]; then
|
||||
echo "固件/tmp空间值[${tmp_available}M],云端固件体积[${cloud_firmware_size}M],空间不足,不能下载"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 固件/tmp空间值[${tmp_available}M],云端固件体积[${cloud_firmware_size}M],空间不足,不能下载" >> ${AUTOUPDATE_LOG}
|
||||
exit 0
|
||||
else
|
||||
echo "固件/tmp空间值[${tmp_available}M],云端固件体积[${cloud_firmware_size}M]"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 固件/tmp空间值[${tmp_available}M],云端固件体积[${cloud_firmware_size}M]" >> ${AUTOUPDATE_LOG}
|
||||
fi
|
||||
|
||||
if [[ "${LOCAL_COMPILE_DATE}" -lt "${CLOUD_COMPILE_DATE}" ]]; then
|
||||
echo "检测到有可更新的固件版本,立即更新固件!"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 检测到有可更新的固件版本,立即更新固件!" >> ${AUTOUPDATE_LOG}
|
||||
elif [[ "${LOCAL_COMPILE_DATE}" -eq "${CLOUD_COMPILE_DATE}" ]]; then
|
||||
echo "已是最新版本,无需更新固件!"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 已是最新版本,无需更新固件!" >> ${AUTOUPDATE_LOG}
|
||||
exit 0
|
||||
elif [[ "${LOCAL_COMPILE_DATE}" -gt "${CLOUD_COMPILE_DATE}" ]]; then
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 云端最高版本固件,低于您现在所安装的版本,请到云端查看原因!" >> ${AUTOUPDATE_LOG}
|
||||
echo "云端最高版本固件,低于您现在所安装的版本!"
|
||||
read -t 60 -p "确定要更新到此固件吗[f/F强制升级,其它退出升级]:" force_update || echo
|
||||
case ${force_update} in
|
||||
f|F)
|
||||
echo
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "开始下载云端固件,请等待..."
|
||||
cd ${DOWNLOAD_PATH}
|
||||
if [[ "$(curl -I -s --connect-timeout 5 google.com -w %{http_code} | tail -n1)" == "301" ]]; then
|
||||
DOWNLOAD1=${FRIMWARE_URL_ORIGIN}
|
||||
DOWNLOAD2=${FRIMWARE_URL_GHPROXY}
|
||||
else
|
||||
DOWNLOAD1=${FRIMWARE_URL_GHPROXY}
|
||||
DOWNLOAD2=${FRIMWARE_URL_ORIGIN}
|
||||
fi
|
||||
|
||||
wget -q --timeout=5 --tries=2 --show-progress ${DOWNLOAD1}/${CLOUD_FIRMWARE_FILENAME} -O ${DOWNLOAD_PATH}/${CLOUD_FIRMWARE_FILENAME}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
curl -fsSL ${DOWNLOAD2}/${CLOUD_FIRMWARE_FILENAME} -o ${CLOUD_FIRMWARE_FILENAME}
|
||||
fi
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "下载云端固件失败,请检查网络再尝试或手动安装固件!"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 下载云端固件失败,请检查网络再尝试或手动安装固件!" >> ${AUTOUPDATE_LOG}
|
||||
exit 0
|
||||
else
|
||||
echo "下载云端固件成功."
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 下载云端固件成功." >> ${AUTOUPDATE_LOG}
|
||||
fi
|
||||
|
||||
local local_md5256=$(md5sum ${CLOUD_FIRMWARE_FILENAME} |cut -c1-3)$(sha256sum ${CLOUD_FIRMWARE_FILENAME} |cut -c1-3)
|
||||
local cloud_md5256=$(echo ${CLOUD_FIRMWARE_FILENAME} |grep -Eo "[a-zA-Z0-9]+${FIRMWARE_EXT}" | sed -r "s/(.*)${FIRMWARE_EXT}/\1/")
|
||||
if [[ "${cloud_md5256}" == "${local_md5256}" ]]; then
|
||||
echo "MD5对比成功."
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') MD5对比成功." >> ${AUTOUPDATE_LOG}
|
||||
sleep 2
|
||||
else
|
||||
echo "MD5对比失败,固件可能在下载时损坏,请检查网络后重试!"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') MD5对比失败,固件可能在下载时损坏,请检查网络后重试!" >> ${AUTOUPDATE_LOG}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "正在执行更新,更新期间请不要断开电源或重启设备 ..."
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 正在执行更新,更新期间请不要断开电源或重启设备 ..." >> ${AUTOUPDATE_LOG}
|
||||
chmod 777 "${CLOUD_FIRMWARE_FILENAME}"
|
||||
if [[ `opkg list | awk '{print $1}' | grep -c gzip` -ge '1' ]]; then
|
||||
opkg remove gzip > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
# 删除不需要的文件
|
||||
if [[ -f ${FILES_TO_DELETE} ]]; then
|
||||
chmod 775 ${FILES_TO_DELETE}
|
||||
source ${FILES_TO_DELETE}
|
||||
fi
|
||||
|
||||
echo "升级固件中,请勿断开路由器电源...END"
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 升级固件中,请勿断开路由器电源...END" >> ${AUTOUPDATE_LOG}
|
||||
sleep 3
|
||||
|
||||
rm -rf /etc/config/luci
|
||||
rm -rf /mnt/*upback.tar.gz && sysupgrade -b /mnt/upback.tar.gz
|
||||
if [[ `ls -1 /mnt | grep -c "upback.tar.gz"` -eq '1' ]]; then
|
||||
local upgrade_options='sysupgrade -F -f /mnt/upback.tar.gz'
|
||||
else
|
||||
local upgrade_options='sysupgrade -F -q'
|
||||
fi
|
||||
${upgrade_options} ${CLOUD_FIRMWARE_FILENAME}
|
||||
}
|
||||
|
||||
function script_help() {
|
||||
echo " 使用: autoupdate [选项]
|
||||
Usage: autoupdate [OPTION]
|
||||
|
||||
-c 检测云端是否存在可供更新固件
|
||||
Check whether the cloud has available OpenWrt firmware that can be upgraded.
|
||||
|
||||
-u 仅检测云端相同源码、LUCI版本的OpenWrt固件是否有可更新,如有则更新
|
||||
List the firmware of the same LUCI version as OpenWrt, and then compare whether it can be upgraded, if it can be upgraded, upgrade it.
|
||||
|
||||
-s 仅检测云端相同源码、LUCI版本的OpenWrt固件是否有可更新,如有则更新
|
||||
List the firmware of the same LUCI version as OpenWrt, and then compare whether it can be upgraded, if it can be upgraded, upgrade it.
|
||||
|
||||
-m 检测云端所有OpenWrt固件是否有可更新,如有则更新
|
||||
List all the firmwares in the cloud to choose from, and then upgrade the OpenWrt system.
|
||||
|
||||
-v 版本
|
||||
Version.
|
||||
|
||||
-h 帮助
|
||||
help.
|
||||
"
|
||||
}
|
||||
|
||||
function main() {
|
||||
[[ ! -d ${TMP_AUTOUPDATE_PATH} ]] && mkdir -p ${TMP_AUTOUPDATE_PATH}
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') 开始运行在线更新程序" >> ${AUTOUPDATE_LOG}
|
||||
|
||||
if [[ -z "${INPUT_OPTION}" ]]; then
|
||||
script_help
|
||||
else
|
||||
case ${INPUT_OPTION} in
|
||||
-c)
|
||||
firmware_check
|
||||
;;
|
||||
-h|--help)
|
||||
script_help
|
||||
;;
|
||||
-u|-s|-m)
|
||||
firmware_upgrade
|
||||
;;
|
||||
-v|--version)
|
||||
echo "${Version}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main "$*"
|
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
# https://github.com/Hyy2001X/AutoBuild-Actions
|
||||
# AutoBuild Module by Hyy2001
|
||||
|
||||
rm -f /tmp/cloud_version
|
||||
rm -f /tmp/Version_Tags
|
||||
if [[ -f /bin/openwrt_info ]]; then
|
||||
chmod +x /bin/openwrt_info
|
||||
bash /bin/AutoUpdate.sh -w
|
||||
else
|
||||
echo "未检测到openwrt_info文件,无法运行更新程序!" > /tmp/cloud_version
|
||||
exit 1
|
||||
fi
|
||||
[[ ! -f /tmp/Version_Tags ]] && echo "未检测到云端版本,请检查网络,或您的仓库为私库,或您修改的Github地址有错误,或发布已被删除,或再次刷新网页试试!" > /tmp/cloud_version && exit 1
|
||||
chmod +x /tmp/Version_Tags && source /tmp/Version_Tags
|
||||
if [[ -n "${CLOUD_Version}" ]];then
|
||||
if [[ "${CURRENT_Version}" -eq "${CLOUD_Version}" ]];then
|
||||
Checked_Type="已是最新"
|
||||
echo "${CLOUD_Version} [${Checked_Type}]" > /tmp/cloud_version
|
||||
elif [[ "${CURRENT_Version}" -gt "${CLOUD_Version}" ]];then
|
||||
Checked_Type="发现更高版本固件可更新"
|
||||
echo "${CLOUD_Version} [${Checked_Type}]" > /tmp/cloud_version
|
||||
elif [[ "${CURRENT_Version}" -lt "${CLOUD_Version}" ]];then
|
||||
Checked_Type="云端最高版本固件,低于您现在所安装的版本"
|
||||
echo "${CLOUD_Version} [${Checked_Type}]" > /tmp/cloud_version
|
||||
fi
|
||||
else
|
||||
echo "没检测到云端固件,您可能把云端固件删除了,或格式不对称,比如爱快虚拟机安装EIF格式都会变成Legacy引导!" > /tmp/cloud_version
|
||||
fi
|
||||
exit 0
|
@ -6,12 +6,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=v2ray-plugin
|
||||
PKG_VERSION:=5.10.0
|
||||
PKG_VERSION:=5.11.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/teddysun/v2ray-plugin/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=2ff37018e8bb6e9208206e84b9b5be77ad3d9a9e62bf2078b871f4f7066a87b8
|
||||
PKG_HASH:=4080dc0597f1c4f4099bdcd5aafd6bce463542eb9b691153c756cab86cd0decb
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
Loading…
Reference in New Issue
Block a user