diff --git a/Customize/AutoUpdate.sh b/Customize/AutoUpdate.sh index 8a1c251..5de9620 100644 --- a/Customize/AutoUpdate.sh +++ b/Customize/AutoUpdate.sh @@ -3,7 +3,7 @@ # AutoBuild Module by Hyy2001 # AutoUpdate -Version=V3.3-BETA +Version=V3.4 DEFAULT_DEVICE=d-team_newifi-d2 Github=https://github.com/Hyy2001X/AutoBuild-Actions @@ -23,18 +23,26 @@ if [[ ! $1 == "" ]];then else Upgrade_Option="-q" fi -if [ "$CURRENT_VERSION" == "" ]; then +opkg list | awk '{print $1}' > /tmp/Package_list +grep "curl" /tmp/Package_list > /dev/null 2>&1 +if [ ! $? -ne 0 ];then + Google_Check=`curl -I -s --connect-timeout 5 www.google.com -w %{http_code} | tail -n1` + [ ! "$Google_Check" == 200 ] && TIME && echo "Google 连接失败,可能导致固件下载速度缓慢!" +fi +grep "wget" /tmp/Package_list > /dev/null 2>&1 +[ $? -ne 0 ] && TIME && echo "未安装 wget!请先执行[opkg update && opkg install wget]" && exit +if [ "$CURRENT_VERSION" == "" ];then echo -e "\n警告:当前固件版本获取失败!" CURRENT_VERSION=未知 fi -if [ "$CURRENT_DEVICE" == "" ]; then +if [ "$CURRENT_DEVICE" == "" ];then echo -e "\n警告:当前设备名称获取失败,使用预设名称[$DEFAULT_DEVICE]" CURRENT_DEVICE=$DEFAULT_DEVICE fi cd /tmp TIME && echo "正在获取云端固件版本..." GET_Version=`wget -q $Github_Tags -O - | egrep -o 'R[0-9]+.[0-9]+.[0-9]+.[0-9]+' | awk 'NR==1'` -if [ "$GET_Version" == "" ]; then +if [ "$GET_Version" == "" ];then TIME && echo "云端固件版本获取失败,请稍后重试!" exit fi @@ -54,10 +62,6 @@ Firmware_Info="AutoBuild-${CURRENT_DEVICE}-Lede-${GET_Version}" Firmware="${Firmware_Info}.bin" Firmware_Detail="${Firmware_Info}.detail" echo "云端固件名称:$Firmware" -Google_Check=`curl -I -s --connect-timeout 5 www.google.com -w %{http_code} | tail -n1` -if [ ! "$Google_Check" == 200 ];then - TIME && echo "Google 连接失败,可能导致固件下载速度缓慢!" -fi TIME && echo "正在下载固件,请耐心等待..." wget -q $Github_Download/$Firmware -O $Firmware if [ ! "$?" == 0 ]; then @@ -80,10 +84,10 @@ if [ "$GET_MD5" == "" ] || [ "$CURRENT_MD5" == "" ];then exit fi if [ ! "$GET_MD5" == "$CURRENT_MD5" ];then - echo -e "\nMD5对比不通过,请检查网络后重试!" + echo -e "\nMD5对比失败,请检查网络后重试!" exit fi -TIME && echo "MD5对比通过,准备升级固件..." +TIME && echo "MD5对比通过!" sleep 3 TIME && echo -e "开始升级固件,请耐心等待...\n" -sysupgrade ${Upgrade_Option} $Firmware \ No newline at end of file +sysupgrade ${Upgrade_Option} $Firmware diff --git a/Customize/banner b/Customize/banner new file mode 100644 index 0000000..050e607 --- /dev/null +++ b/Customize/banner @@ -0,0 +1,8 @@ + _______ ________ __ + | |.-----.-----.-----.| | | |.----.| |_ + | - || _ | -__| || | | || _|| _| + |_______|| __|_____|__|__||________||__| |____| + |__| W I R E L E S S F R E E D O M + ----------------------------------------------------- + Openwrt + ----------------------------------------------------- diff --git a/README.md b/README.md index 56d0f67..6283cae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,34 @@ # AutoBuild-Actions + Actions for Building OpenWRT -Supported Devices: `d-team_newifi-d2` +测试通过的设备: **!x86**、`d-team_newifi-d2`、`phicomm_k2p` -使用方法参考 CurssedCoffin老哥 的 [AutoBuild-Actions](https://github.com/CurssedCoffin/AutoBuild-Actions) +使用方法/Usage: +------ + +1. 首先需要获取[Github Token](https://github.com/settings/tokens/new),`Note`项随意填写,`Select scopes`项如果不懂就全部打勾,完成后点击`Generate token` + +2. 复制获取到的Token值,**一定要保存到本地,Token值只会显示一次!** + +3. `Fork`此仓库,然后进入到你的`AutoBuild-Actions`仓库 + +4. 点击右上方菜单中的`Settings`,点击`Secrets`-`New Secrets`,`Name`项填写`RELEASE_TOKEN`,`Value`项填写你在第 1 步中获取到的Token + +客制化固件: +------ + +1. 进入到你的`AutoBuild-Actions`仓库 + +2. 编辑`/Customize/AutoUpdate.sh`文件,修改`第 7 行`为你要编译的设备名称,修改`第 8 行`为你的 Github 地址 + +3. 编辑`/Sctipts/diy-script.sh`文件,修改`第 7 行`为作者,作者将在路由器后台显示`Compiled by Hyy2001` + +4. **添加额外的软件包:** 编辑`Scrips/diy-script.sh`中的 `Diy-Part1()` 函数,参照下方语法添加第三方包到源码 +``` + [git clone] ExtraPackages git Github仓库 远程分支 + + [svn checkout] ExtraPackages svn Github仓库/trunk +``` + +5. **添加自定义文件:** 首先上传自定义文件到`/Customize`,然后编辑 `Diy-Part1()` 函数,参照参照现有 `mv2` 语法添加自定义文件到源码 diff --git a/Scripts/diy-script.sh b/Scripts/diy-script.sh index 2dcf0a0..dd553f1 100644 --- a/Scripts/diy-script.sh +++ b/Scripts/diy-script.sh @@ -8,9 +8,11 @@ Author=Hyy2001 Default_File=./package/lean/default-settings/files/zzz-default-settings Lede_Version=`egrep -o "R[0-9]+\.[0-9]+\.[0-9]+" $Default_File` +Openwrt_Version="$Lede_Version-`date +%Y%m%d`" +AutoUpdate_Version=`awk 'NR==6' ./package/base-files/files/bin/AutoUpdate.sh | awk -F'[="]+' '/Version/{print $2}'` Compile_Date=`date +'%Y/%m/%d'` Compile_Time=`date +'%Y-%m-%d %H:%M:%S'` -TARGET_PROFILE=`egrep -o "CONFIG_TARGET.*DEVICE.*=y" .config | sed -r 's/.*DEVICE_(.*)=y/\1/'` +TARGET_PROFILE=`grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' | awk 'NR==1'` } GET_TARGET_INFO() { @@ -69,6 +71,7 @@ mv2 system package/base-files/files/etc/config mv2 mwan3 package/base-files/files/etc/config mv2 AutoUpdate.sh package/base-files/files/bin mv2 firewall.config package/network/config/firewall/files +mv2 banner package/base-files/files/etc ExtraPackages git luci-theme-argon https://github.com/jerrykuku 18.06 ExtraPackages svn luci-app-adguardhome https://github.com/Lienol/openwrt/trunk/package/diy @@ -81,17 +84,19 @@ ExtraPackages svn luci-app-socat https://github.com/xiaorouji/openwrt-package/tr Diy-Part2() { echo "Author: $Author" -echo "Current Openwrt version: $Lede_Version-`date +%Y%m%d`" +echo "Current Openwrt Version: $Openwrt_Version" +echo "Current AutoUpdate Version: $AutoUpdate_Version" echo "Current Device: $TARGET_PROFILE" sed -i "s?$Lede_Version?$Lede_Version Compiled by $Author [$Compile_Date]?g" $Default_File -echo "$Lede_Version-`date +%Y%m%d`" > ./package/base-files/files/etc/openwrt_info +echo "$Openwrt_Version" > ./package/base-files/files/etc/openwrt_info +sed -i "s?Openwrt?Openwrt $Openwrt_Version / AutoUpdate $AutoUpdate_Version?g" ./package/base-files/files/etc/banner } Diy-Part3() { GET_TARGET_INFO Default_Firmware=openwrt-$TARGET_BOARD-$TARGET_SUBTARGET-$TARGET_PROFILE-squashfs-sysupgrade.bin -AutoBuild_Firmware=AutoBuild-$TARGET_PROFILE-Lede-$Lede_Version`(date +-%Y%m%d.bin)` -AutoBuild_Detail=AutoBuild-$TARGET_PROFILE-Lede-$Lede_Version`(date +-%Y%m%d.detail)` +AutoBuild_Firmware=AutoBuild-$TARGET_PROFILE-Lede-${Openwrt_Version}.bin +AutoBuild_Detail=AutoBuild-$TARGET_PROFILE-Lede-${Openwrt_Version}.detail mkdir -p ./bin/Firmware echo "[$(date "+%H:%M:%S")] Moving $Default_Firmware to /bin/Firmware/$AutoBuild_Firmware ..." mv ./bin/targets/$TARGET_BOARD/$TARGET_SUBTARGET/$Default_Firmware ./bin/Firmware/$AutoBuild_Firmware