Skip to content

Commit

Permalink
chore: refine
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Feb 17, 2025
1 parent 3feb659 commit ebab3ae
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 132 deletions.
16 changes: 7 additions & 9 deletions luci-app-openclash/root/usr/share/openclash/clash_version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
. /usr/share/openclash/openclash_curl.sh

set_lock() {
exec 884>"/tmp/lock/openclash_clash_version.lock" 2>/dev/null
Expand All @@ -14,27 +15,24 @@ set_lock

TIME=$(date "+%Y-%m-%d-%H")
CHTIME=$(date "+%Y-%m-%d-%H" -r "/tmp/clash_last_version" 2>/dev/null)
LAST_OPVER="/tmp/clash_last_version"
DOWNLOAD_FILE="/tmp/clash_last_version"
RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master")
github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0)
if [ -n "$1" ]; then
github_address_mod="$1"
fi
LOG_FILE="/tmp/openclash.log"

if [ "$TIME" != "$CHTIME" ]; then
if [ "$github_address_mod" != "0" ]; then
if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then
curl -SsL -m 60 "$github_address_mod"gh/vernesong/OpenClash@core/"$RELEASE_BRANCH"/core_version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_URL="${github_address_mod}gh/vernesong/OpenClash@core/${RELEASE_BRANCH}/core_version"
else
curl -SsL -m 60 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/core_version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_URL="${github_address_mod}https://raw.githubusercontent.com/vernesong/OpenClash/core/${RELEASE_BRANCH}/core_version"
fi
else
curl -SsL -m 60 https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/core_version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
fi

if [ "${PIPESTATUS[0]}" -ne 0 ]; then
rm -rf $LAST_OPVER
DOWNLOAD_URL="https://raw.githubusercontent.com/vernesong/OpenClash/core/${RELEASE_BRANCH}/core_version"
fi

DOWNLOAD_FILE_CURL "$DOWNLOAD_URL" "$DOWNLOAD_FILE"
fi
del_lock
23 changes: 12 additions & 11 deletions luci-app-openclash/root/usr/share/openclash/openclash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
. /usr/share/openclash/openclash_ps.sh
. /usr/share/openclash/log.sh
. /lib/functions/procd.sh
. /usr/share/openclash/openclash_curl.sh

set_lock() {
exec 889>"/tmp/lock/openclash_subs.lock" 2>/dev/null
Expand Down Expand Up @@ -70,16 +71,20 @@ config_download()
LOG_OUT "Tip: Config File【$name】Downloading User-Agent【$sub_ua】..."
if [ -n "$subscribe_url_param" ]; then
if [ -n "$c_address" ]; then
echo "$LOGTIME Tip: Config File【$name】Downloading URL【$c_address$subscribe_url_param】..." >> $LOG_FILE
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 -H "$sub_ua" "$c_address""$subscribe_url_param" -o "$CFG_FILE" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$CFG_FILE" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
LOG_OUT "Tip: Config File【$name】Downloading URL【$c_address$subscribe_url_param】..."
DOWNLOAD_URL="${c_address}${subscribe_url_param}"
DOWNLOAD_PARAM="$sub_ua"
else
echo "$LOGTIME Tip: Config File【$name】Downloading URL【https://api.dler.io/sub$subscribe_url_param】..." >> $LOG_FILE
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 -H "$sub_ua" https://api.dler.io/sub"$subscribe_url_param" -o "$CFG_FILE" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$CFG_FILE" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
LOG_OUT "Tip: Config File【$name】Downloading URL【https://api.dler.io/sub$subscribe_url_param】..."
DOWNLOAD_URL="https://api.dler.io/sub${subscribe_url_param}"
DOWNLOAD_PARAM="$sub_ua"
fi
else
echo "$LOGTIME Tip: Config File【$name】Downloading URL【$subscribe_url】..." >> $LOG_FILE
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 -H "$sub_ua" "$subscribe_url" -o "$CFG_FILE" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$CFG_FILE" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
LOG_OUT "Tip: Config File【$name】Downloading URL【$subscribe_url】..."
DOWNLOAD_URL="${subscribe_url}"
DOWNLOAD_PARAM="$sub_ua"
fi
DOWNLOAD_FILE_CURL "$DOWNLOAD_URL" "$CFG_FILE" "$DOWNLOAD_PARAM"
}

config_cus_up()
Expand Down Expand Up @@ -382,7 +387,7 @@ sub_info_get()
config_get "rule_provider" "$section" "rule_provider" ""
config_get "custom_template_url" "$section" "custom_template_url" ""
config_get "de_ex_keyword" "$section" "de_ex_keyword" ""
config_get "sub_ua" "$section" "sub_ua" "Clash"
config_get "sub_ua" "$section" "sub_ua" "clash.meta"

if [ "$enabled" -eq 0 ]; then
if [ -n "$2" ]; then
Expand All @@ -403,10 +408,6 @@ sub_info_get()
else
udp=""
fi

if [ -n "$sub_ua" ]; then
sub_ua="User-Agent: $sub_ua"
fi

if [ "$rule_provider" == "true" ]; then
rule_provider="&expand=false&classic=true"
Expand Down
24 changes: 9 additions & 15 deletions luci-app-openclash/root/usr/share/openclash/openclash_chnroute.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
. /usr/share/openclash/openclash_ps.sh
. /usr/share/openclash/log.sh

. /usr/share/openclash/openclash_curl.sh

set_lock() {
exec 879>"/tmp/lock/openclash_chn.lock" 2>/dev/null
Expand All @@ -24,7 +24,6 @@
disable_udp_quic=$(uci -q get openclash.config.disable_udp_quic)
small_flash_memory=$(uci -q get openclash.config.small_flash_memory)
en_mode=$(uci -q get openclash.config.en_mode)
LOG_FILE="/tmp/openclash.log"
restart=0


Expand All @@ -40,17 +39,12 @@

LOG_OUT "Start Downloading The Chnroute Cidr List..."
if [ -z "$CHNR_CUSTOM_URL" ]; then
if pidof clash >/dev/null; then
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://ispip.clang.cn/all_cn.txt -o /tmp/china_ip_route.txt 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/china_ip_route.txt" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
fi
if [ "${PIPESTATUS[0]}" != "0" ] || ! pidof clash >/dev/null; then
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://ispip.clang.cn/all_cn_cidr.txt -o /tmp/china_ip_route.txt 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/china_ip_route.txt" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
fi
DOWNLOAD_FILE_CURL "https://ispip.clang.cn/all_cn.txt" "/tmp/china_ip_route.txt"
else
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$CHNR_CUSTOM_URL" -o /tmp/china_ip_route.txt 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/china_ip_route.txt" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_FILE_CURL "$CHNR_CUSTOM_URL" "/tmp/china_ip_route.txt"
fi

if [ "${PIPESTATUS[0]}" -eq 0 ] && [ -s "/tmp/china_ip_route.txt" ]; then
if [ "$?" -eq 0 ]; then
LOG_OUT "Chnroute Cidr List Download Success, Check Updated..."
#预处理
if [ -n "$FW4" ]; then
Expand All @@ -64,7 +58,7 @@
awk '!/^$/&&!/^#/{printf("add china_ip_route %s'" "'\n",$0)}' /tmp/china_ip_route.txt >>/tmp/china_ip_route.list
fi
cmp -s /tmp/china_ip_route.list "$chnr_path"
if [ "$?" -ne "0" ]; then
if [ "$?" -ne 0 ]; then
LOG_OUT "Chnroute Cidr List Has Been Updated, Starting To Replace The Old Version..."
mv /tmp/china_ip_route.list "$chnr_path" >/dev/null 2>&1
if [ "$china_ip_route" -ne 0 ] || [ "$disable_udp_quic" -eq 1 ]; then
Expand All @@ -81,11 +75,11 @@
#ipv6
LOG_OUT "Start Downloading The Chnroute6 Cidr List..."
if [ -z "$CHNR6_CUSTOM_URL" ]; then
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://ispip.clang.cn/all_cn_ipv6.txt -o /tmp/china_ip6_route.txt 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/china_ip6_route.txt" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_FILE_CURL "https://ispip.clang.cn/all_cn_ipv6.txt" "/tmp/china_ip6_route.txt"
else
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$CHNR6_CUSTOM_URL" -o /tmp/china_ip6_route.txt 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/china_ip6_route.txt" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_FILE_CURL "$CHNR6_CUSTOM_URL" "/tmp/china_ip6_route.txt"
fi
if [ "${PIPESTATUS[0]}" -eq "0" ] && [ -s "/tmp/china_ip6_route.txt" ]; then
if [ "$?" -eq 0 ]; then
LOG_OUT "Chnroute6 Cidr List Download Success, Check Updated..."
#预处理
if [ -n "$FW4" ]; then
Expand All @@ -99,7 +93,7 @@
awk '!/^$/&&!/^#/{printf("add china_ip6_route %s'" "'\n",$0)}' /tmp/china_ip6_route.txt >>/tmp/china_ip6_route.list
fi
cmp -s /tmp/china_ip6_route.list "$chnr6_path"
if [ "$?" -ne "0" ]; then
if [ "$?" -ne 0 ]; then
LOG_OUT "Chnroute6 Cidr List Has Been Updated, Starting To Replace The Old Version..."
mv /tmp/china_ip6_route.list "$chnr6_path" >/dev/null 2>&1
if [ "$china_ip6_route" -ne 0 ] || [ "$disable_udp_quic" -eq 1 ]; then
Expand Down
77 changes: 40 additions & 37 deletions luci-app-openclash/root/usr/share/openclash/openclash_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
. /lib/functions.sh
. /usr/share/openclash/openclash_ps.sh
. /usr/share/openclash/log.sh
. /usr/share/openclash/openclash_curl.sh

set_lock() {
exec 872>"/tmp/lock/openclash_core.lock" 2>/dev/null
Expand Down Expand Up @@ -31,7 +32,7 @@ C_CORE_TYPE=$(uci -q get openclash.config.core_type)
small_flash_memory=$(uci -q get openclash.config.small_flash_memory)
CPU_MODEL=$(uci -q get openclash.config.core_version)
RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master")
LOG_FILE="/tmp/openclash.log"
DOWNLOAD_FILE="/tmp/clash_meta.tar.gz"

if [ "$github_address_mod" != "0" ]; then
[ ! -f "/tmp/clash_last_version" ] && /usr/share/openclash/clash_version.sh "$github_address_mod" 2>/dev/null
Expand Down Expand Up @@ -64,58 +65,60 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then
LOG_OUT "【Meta】Core Downloading, Please Try to Download and Upload Manually If Fails"
if [ "$github_address_mod" != "0" ]; then
if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_meta.tar.gz 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/clash_meta.tar.gz" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_URL="${github_address_mod}gh/vernesong/OpenClash@core/${RELEASE_BRANCH}/meta/clash-${CPU_MODEL}.tar.gz"
else
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_meta.tar.gz 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/clash_meta.tar.gz" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_URL="${github_address_mod}https://raw.githubusercontent.com/vernesong/OpenClash/core/${RELEASE_BRANCH}/meta/clash-${CPU_MODEL}.tar.gz"
fi
else
curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_meta.tar.gz 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/clash_meta.tar.gz" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"
DOWNLOAD_URL="https://raw.githubusercontent.com/vernesong/OpenClash/core/${RELEASE_BRANCH}/meta/clash-${CPU_MODEL}.tar.gz"
fi

if [ "${PIPESTATUS[0]}" -eq 0 ]; then
gzip -t /tmp/clash_meta.tar.gz >/dev/null 2>&1
fi
DOWNLOAD_FILE_CURL "$DOWNLOAD_URL" "$DOWNLOAD_FILE"

if [ "$?" == "0" ]; then
LOG_OUT ""$CORE_TYPE"】Core Download Successful, Start Update..."
[ -s "/tmp/clash_meta.tar.gz" ] && {
tar zxvfo /tmp/clash_meta.tar.gz -C /tmp >/dev/null 2>&1
mv /tmp/clash /tmp/clash_meta >/dev/null 2>&1
rm -rf /tmp/clash_meta.tar.gz >/dev/null 2>&1
chmod 4755 /tmp/clash_meta >/dev/null 2>&1
/tmp/clash_meta -v >/dev/null 2>&1
}

if [ "$?" != "0" ]; then
LOG_OUT ""$CORE_TYPE"】Core Update Failed. Please Make Sure Enough Flash Memory Space or Selected Correct Core Platform And Try Again!"
rm -rf /tmp/clash_meta >/dev/null 2>&1
SLOG_CLEAN
del_lock
exit 0
fi
if [ "$?" -eq 0 ]; then
gzip -t "$DOWNLOAD_FILE" >/dev/null 2>&1

mv /tmp/clash_meta "$meta_core_path" >/dev/null 2>&1
if [ "$?" -eq 0 ]; then
LOG_OUT ""$CORE_TYPE"】Core Download Successful, Start Update..."
[ -s "$DOWNLOAD_FILE" ] && {
tar zxvfo "$DOWNLOAD_FILE" -C /tmp >/dev/null 2>&1
mv /tmp/clash /tmp/clash_meta >/dev/null 2>&1
rm -rf "$DOWNLOAD_FILE" >/dev/null 2>&1
chmod 4755 /tmp/clash_meta >/dev/null 2>&1
/tmp/clash_meta -v >/dev/null 2>&1
}

if [ "$?" != "0" ]; then
LOG_OUT ""$CORE_TYPE"】Core Update Failed. Please Make Sure Enough Flash Memory Space or Selected Correct Core Platform And Try Again!"
rm -rf /tmp/clash_meta >/dev/null 2>&1
SLOG_CLEAN
del_lock
exit 0
fi

mv /tmp/clash_meta "$meta_core_path" >/dev/null 2>&1

if [ "$?" == "0" ]; then
LOG_OUT ""$CORE_TYPE"】Core Update Successful!"
if [ "$if_restart" -eq 1 ]; then
uci -q set openclash.config.restart=1
uci -q commit openclash
if ([ -z "$2" ] || ([ -n "$2" ] && [ "$2" != "one_key_update" ])) && [ "$(unify_ps_prevent)" -eq 0 ]; then
uci -q set openclash.config.restart=0
if [ "$?" == "0" ]; then
LOG_OUT ""$CORE_TYPE"】Core Update Successful!"
if [ "$if_restart" -eq 1 ]; then
uci -q set openclash.config.restart=1
uci -q commit openclash
/etc/init.d/openclash restart >/dev/null 2>&1 &
if ([ -z "$2" ] || ([ -n "$2" ] && [ "$2" != "one_key_update" ])) && [ "$(unify_ps_prevent)" -eq 0 ]; then
uci -q set openclash.config.restart=0
uci -q commit openclash
/etc/init.d/openclash restart >/dev/null 2>&1 &
fi
else
SLOG_CLEAN
fi
else
LOG_OUT ""$CORE_TYPE"】Core Update Failed. Please Make Sure Enough Flash Memory Space And Try Again!"
SLOG_CLEAN
fi
else
LOG_OUT ""$CORE_TYPE"】Core Update Failed. Please Make Sure Enough Flash Memory Space And Try Again!"
LOG_OUT ""$CORE_TYPE"】Core Update Failed, Please Check The Network or Try Again Later!"
SLOG_CLEAN
fi
else
LOG_OUT ""$CORE_TYPE"】Core Update Failed, Please Check The Network or Try Again Later!"
SLOG_CLEAN
fi
else
LOG_OUT "No Compiled Version Selected, Please Select In Update Page And Try Again!"
Expand Down
22 changes: 22 additions & 0 deletions luci-app-openclash/root/usr/share/openclash/openclash_curl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
. /usr/share/openclash/log.sh

DOWNLOAD_FILE_CURL() {
[ -z "$1" ] || [ -z "$2" ] && return 1
DOWNLOAD_URL=$1
DOWNLOAD_PATH=$2
DOWNLOAD_UA=$3
[ -z "$DOWNLOAD_UA" ] && DOWNLOAD_UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
OUTPUT=$(curl -w "%{http_code}" -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 -H "User-Agent: ${DOWNLOAD_UA}" "$DOWNLOAD_URL" -o "$DOWNLOAD_PATH" 2>&1)
EXIR_CODE=${PIPESTATUS[0]}
HTTP_CODE=$(echo "$OUTPUT" | tail -n1)
OUTPUT=$(echo "$OUTPUT" | sed '$d' | sed ':a;N;$!ba; s/\n/ /g')
if [ "$EXIR_CODE" -ne 0 ] || [ "$HTTP_CODE" -ne 200 ]; then
LOG_OUT "$DOWNLOAD_PATH】Download Failed:【$OUTPUT"
rm -rf $DOWNLOAD_PATH
SLOG_CLEAN
return 1
else
return 0
fi
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
. /usr/share/openclash/log.sh
. /lib/functions.sh
. /usr/share/openclash/openclash_curl.sh

set_lock() {
exec 871>"/tmp/lock/openclash_dashboard.lock" 2>/dev/null
Expand All @@ -18,7 +19,6 @@
DASH_TYPE="$2"
DASH_FILE_DIR="/tmp/dash.zip"
DASH_FILE_TMP="/tmp/dash/"
LOG_FILE="/tmp/openclash.log"
github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0)
if [ "$DASH_NAME" == "Dashboard" ]; then
UNPACK_FILE_DIR="/usr/share/openclash/ui/dashboard/"
Expand Down Expand Up @@ -51,10 +51,10 @@
DOWNLOAD_PATH="https://codeload.github.com/MetaCubeX/metacubexd/zip/refs/heads/gh-pages"
FILE_PATH_INCLUDE="metacubexd-gh-pages"
fi

curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$DOWNLOAD_PATH" -o "$DASH_FILE_DIR" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$DASH_FILE_DIR" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE"

if [ "${PIPESTATUS[0]}" -eq 0 ] && [ -s "$DASH_FILE_DIR" ] && [ -z "$(grep "404: Not Found" "$DASH_FILE_DIR")" ] && [ -z "$(grep "Package size exceeded the configured limit" "$DASH_FILE_DIR")" ]; then
DOWNLOAD_FILE_CURL "$DOWNLOAD_PATH" "$DASH_FILE_DIR"

if [ "$?" -eq 0 ] && [ -s "$DASH_FILE_DIR" ]; then
unzip -qt "$DASH_FILE_DIR" >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
cp -rf "$UNPACK_FILE_DIR". "$BACKUP_FILE_DIR" >/dev/null 2>&1
Expand Down
Loading

0 comments on commit ebab3ae

Please sign in to comment.