2020-09-16 15:21:52 +00:00
|
|
|
#!/bin/bash
|
2020-09-16 15:45:32 +00:00
|
|
|
# https://github.com/Hyy2001X/AutoBuild-Actions
|
|
|
|
# AutoBuild Module by Hyy2001
|
2020-09-16 15:21:52 +00:00
|
|
|
# AutoBuild Actions
|
|
|
|
|
|
|
|
Diy_Core() {
|
|
|
|
Author=Hyy2001
|
2020-09-16 15:45:32 +00:00
|
|
|
|
2020-09-19 07:37:55 +00:00
|
|
|
Default_File=./package/lean/default-settings/files/zzz-default-settings
|
|
|
|
Lede_Version=`egrep -o "R[0-9]+\.[0-9]+\.[0-9]+" $Default_File`
|
2020-09-29 06:17:03 +00:00
|
|
|
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}'`
|
2020-09-16 15:45:32 +00:00
|
|
|
Compile_Date=`date +'%Y/%m/%d'`
|
|
|
|
Compile_Time=`date +'%Y-%m-%d %H:%M:%S'`
|
2020-09-29 06:17:03 +00:00
|
|
|
TARGET_PROFILE=`grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' | awk 'NR==1'`
|
2020-09-16 15:21:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 07:37:55 +00:00
|
|
|
GET_TARGET_INFO() {
|
|
|
|
TARGET_BOARD=`awk -F'[="]+' '/TARGET_BOARD/{print $2}' .config`
|
|
|
|
TARGET_SUBTARGET=`awk -F'[="]+' '/TARGET_SUBTARGET/{print $2}' .config`
|
|
|
|
}
|
|
|
|
|
2020-09-16 15:21:52 +00:00
|
|
|
ExtraPackages() {
|
|
|
|
[ -d ./package/lean/$2 ] && rm -rf ./package/lean/$2
|
|
|
|
[ -d ./$2 ] && rm -rf ./$2
|
|
|
|
while [ ! -f $2/Makefile ]
|
|
|
|
do
|
|
|
|
echo "[$(date "+%H:%M:%S")] Checking out $2 from $3 ..."
|
|
|
|
if [ $1 == git ];then
|
|
|
|
git clone -b $4 $3/$2 $2 > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
svn checkout $3/$2 $2 > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
if [ -f $2/Makefile ] || [ -f $2/README* ];then
|
|
|
|
echo "[$(date "+%H:%M:%S")] Package $2 detected!"
|
|
|
|
if [ $2 == OpenClash ];then
|
|
|
|
mv $2/luci-app-openclash ./package/lean
|
|
|
|
else
|
|
|
|
mv $2 ./package/lean
|
|
|
|
fi
|
|
|
|
rm -rf ./$2 > /dev/null 2>&1
|
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "[$(date "+%H:%M:%S")] Checkout failed,retry in 3s."
|
|
|
|
rm -rf ./$2 > /dev/null 2>&1
|
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-09-25 15:54:23 +00:00
|
|
|
mv2() {
|
|
|
|
if [ -f $GITHUB_WORKSPACE/Customize/$1 ];then
|
|
|
|
if [ ! -d ./$2 ];then
|
|
|
|
echo "[$(date "+%H:%M:%S")] Creating new folder $2 ..."
|
|
|
|
mkdir ./$2
|
|
|
|
fi
|
2020-09-26 16:05:06 +00:00
|
|
|
[ -f ./$2/$1 ] && rm -f ./$2/$1
|
2020-09-25 15:54:23 +00:00
|
|
|
echo "[$(date "+%H:%M:%S")] Moving Customize/$1 to $2 ..."
|
|
|
|
mv -f $GITHUB_WORKSPACE/Customize/$1 ./$2/$1
|
|
|
|
else
|
|
|
|
echo "[$(date "+%H:%M:%S")] No $1 file detected!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-16 15:21:52 +00:00
|
|
|
Diy-Part1() {
|
|
|
|
sed -i "s/#src-git helloworld/src-git helloworld/g" feeds.conf.default
|
2020-09-16 15:45:32 +00:00
|
|
|
[ ! -d ./package/lean ] && mkdir ./package/lean
|
2020-09-25 15:54:23 +00:00
|
|
|
|
|
|
|
mv2 mac80211.sh package/kernel/mac80211/files/lib/wifi
|
|
|
|
mv2 system package/base-files/files/etc/config
|
2020-09-28 14:35:29 +00:00
|
|
|
mv2 mwan3 package/base-files/files/etc/config
|
2020-09-25 15:54:23 +00:00
|
|
|
mv2 AutoUpdate.sh package/base-files/files/bin
|
2020-09-26 16:05:06 +00:00
|
|
|
mv2 firewall.config package/network/config/firewall/files
|
2020-09-29 06:17:03 +00:00
|
|
|
mv2 banner package/base-files/files/etc
|
2020-09-25 15:54:23 +00:00
|
|
|
|
2020-09-16 15:21:52 +00:00
|
|
|
ExtraPackages git luci-theme-argon https://github.com/jerrykuku 18.06
|
2020-09-30 10:42:46 +00:00
|
|
|
#ExtraPackages svn luci-app-adguardhome https://github.com/Lienol/openwrt/trunk/package/diy
|
|
|
|
ExtraPackages git luci-app-adguardhome https://github.com/Hyy2001X master
|
2020-09-16 15:21:52 +00:00
|
|
|
ExtraPackages svn luci-app-smartdns https://github.com/project-openwrt/openwrt/trunk/package/ntlf9t
|
|
|
|
ExtraPackages svn smartdns https://github.com/project-openwrt/openwrt/trunk/package/ntlf9t
|
|
|
|
ExtraPackages git OpenClash https://github.com/vernesong master
|
2020-09-20 03:02:10 +00:00
|
|
|
ExtraPackages git luci-app-serverchan https://github.com/tty228 master
|
|
|
|
ExtraPackages svn luci-app-socat https://github.com/xiaorouji/openwrt-package/trunk/lienol
|
2020-09-16 15:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Diy-Part2() {
|
2020-09-23 09:40:48 +00:00
|
|
|
echo "Author: $Author"
|
2020-09-29 06:17:03 +00:00
|
|
|
echo "Current Openwrt Version: $Openwrt_Version"
|
|
|
|
echo "Current AutoUpdate Version: $AutoUpdate_Version"
|
2020-09-19 09:19:41 +00:00
|
|
|
echo "Current Device: $TARGET_PROFILE"
|
|
|
|
sed -i "s?$Lede_Version?$Lede_Version Compiled by $Author [$Compile_Date]?g" $Default_File
|
2020-09-29 06:17:03 +00:00
|
|
|
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
|
2020-09-16 15:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Diy-Part3() {
|
2020-09-19 07:37:55 +00:00
|
|
|
GET_TARGET_INFO
|
2020-09-25 15:54:23 +00:00
|
|
|
Default_Firmware=openwrt-$TARGET_BOARD-$TARGET_SUBTARGET-$TARGET_PROFILE-squashfs-sysupgrade.bin
|
2020-09-29 06:17:03 +00:00
|
|
|
AutoBuild_Firmware=AutoBuild-$TARGET_PROFILE-Lede-${Openwrt_Version}.bin
|
|
|
|
AutoBuild_Detail=AutoBuild-$TARGET_PROFILE-Lede-${Openwrt_Version}.detail
|
2020-09-16 15:21:52 +00:00
|
|
|
mkdir -p ./bin/Firmware
|
2020-09-19 09:35:36 +00:00
|
|
|
echo "[$(date "+%H:%M:%S")] Moving $Default_Firmware to /bin/Firmware/$AutoBuild_Firmware ..."
|
2020-09-16 15:21:52 +00:00
|
|
|
mv ./bin/targets/$TARGET_BOARD/$TARGET_SUBTARGET/$Default_Firmware ./bin/Firmware/$AutoBuild_Firmware
|
2020-09-19 09:35:36 +00:00
|
|
|
echo "[$(date "+%H:%M:%S")] Calculating MD5 and SHA256 ..."
|
2020-09-23 09:40:48 +00:00
|
|
|
Firmware_MD5=`md5sum ./bin/Firmware/$AutoBuild_Firmware | cut -d ' ' -f1`
|
|
|
|
Firmware_SHA256=`sha256sum ./bin/Firmware/$AutoBuild_Firmware | cut -d ' ' -f1`
|
|
|
|
echo "编译日期:$Compile_Time" > ./bin/Firmware/$AutoBuild_Detail
|
|
|
|
echo -e "\nMD5:$Firmware_MD5\nSHA256:$Firmware_SHA256" >> ./bin/Firmware/$AutoBuild_Detail
|
2020-09-16 15:21:52 +00:00
|
|
|
}
|