|
@@ -13,15 +13,21 @@ check_if_already_running(){
|
|
|
[ "${running_tasks}" -gt "2" ] && echo -e "\nA task is already running." && EXIT 2
|
|
|
}
|
|
|
|
|
|
+check_wgetcurl(){
|
|
|
+ which curl && downloader="curl -L -k --retry 2 --connect-timeout 20 -o" && return
|
|
|
+ which wget-ssl && downloader="wget-ssl --no-check-certificate -t 2 -T 20 -O" && return
|
|
|
+ [ -z "$1" ] && opkg update || (echo error opkg && EXIT 1)
|
|
|
+ [ -z "$1" ] && (opkg remove wget wget-nossl --force-depends ; opkg install wget ; check_wgetcurl 1 ;return)
|
|
|
+ [ "$1" == "1" ] && (opkg install curl ; check_wgetcurl 2 ; return)
|
|
|
+ echo error curl and wget && EXIT 1
|
|
|
+}
|
|
|
check_latest_version(){
|
|
|
- latest_ver="$(wget -O- https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E 'v[0-9.]+' -o 2>/dev/null)"
|
|
|
+ check_wgetcurl
|
|
|
+ latest_ver="$($downloader - https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E 'v[0-9.]+' -o 2>/dev/null)"
|
|
|
if [ -z "${latest_ver}" ]; then
|
|
|
- wget -V | grep +https >/dev/null || (opkg update && opkg remove wget-nossl --force-depends && opkg install wget && check_latest_version && EXIT 0)
|
|
|
echo -e "\nFailed to check latest version, please try again later." && EXIT 1
|
|
|
fi
|
|
|
- touch /var/run/AdGfakeconfig
|
|
|
- now_ver="$($binpath -c /var/run/AdGfakeconfig --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o)"
|
|
|
- rm /var/run/AdGfakeconfig
|
|
|
+ now_ver="$($binpath -c /dev/null --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o)"
|
|
|
if [ "${latest_ver}"x != "${now_ver}"x ] || [ "$1" == "force" ]; then
|
|
|
echo -e "Local version: ${now_ver}., cloud version: ${latest_ver}."
|
|
|
doupdate_core
|
|
@@ -96,10 +102,10 @@ doupx(){
|
|
|
EXIT 1
|
|
|
;;
|
|
|
esac
|
|
|
- upx_latest_ver="$(wget -O- https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E '[0-9.]+' -o 2>/dev/null)"
|
|
|
- wget-ssl --no-check-certificate -t 1 -T 10 -O /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/upx-${upx_latest_ver}-${Arch}_linux.tar.xz" 2>&1
|
|
|
+ upx_latest_ver="$($downloader - https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E '[0-9.]+' -o 2>/dev/null)"
|
|
|
+ $downloader /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/upx-${upx_latest_ver}-${Arch}_linux.tar.xz" 2>&1
|
|
|
#tar xvJf
|
|
|
- which xz || (opkg update && opkg install xz) || (echo "xz download fail" && EXIT 1)
|
|
|
+ which xz || (opkg list | grep ^xz || opkg update && opkg install xz) || (echo "xz download fail" && EXIT 1)
|
|
|
mkdir -p /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
|
|
xz -d -c /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz| tar -x -C "/tmp" >/dev/null 2>&1
|
|
|
if [ ! -e "/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx" ]; then
|
|
@@ -165,7 +171,7 @@ doupdate_core(){
|
|
|
while read link
|
|
|
do
|
|
|
eval link="$link"
|
|
|
- wget-ssl --no-check-certificate -t 2 -T 20 -O /tmp/AdGuardHomeupdate/${link##*/} "$link" 2>&1
|
|
|
+ $downloader /tmp/AdGuardHomeupdate/${link##*/} "$link" 2>&1
|
|
|
if [ "$?" != "0" ]; then
|
|
|
echo "download failed try another download"
|
|
|
rm -f /tmp/AdGuardHomeupdate/${link##*/}
|
|
@@ -196,7 +202,7 @@ doupdate_core(){
|
|
|
rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
|
|
fi
|
|
|
echo -e "start copy"
|
|
|
- /etc/init.d/AdGuardHome stop
|
|
|
+ /etc/init.d/AdGuardHome stop nobackup
|
|
|
rm "$binpath"
|
|
|
mv -f "$downloadbin" "$binpath"
|
|
|
if [ "$?" == "1" ]; then
|