Skip to content

Commit

Permalink
chore: refine apk upgrade codes
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Dec 7, 2024
1 parent 9764e5b commit eb716c1
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions luci-app-openclash/root/usr/share/openclash/openclash_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1
fi

if [ "${PIPESTATUS[0]}" -eq 0 ]; then
LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..."
if [ -x "/bin/opkg" ]; then
if [ -s "/tmp/openclash.ipk" ]; then
LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..."

if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then
LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!"
if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then
Expand All @@ -102,8 +101,24 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1
exit 0
fi
fi
LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..."
elif [ -x "/usr/bin/apk" ]; then
if [ -s "/tmp/openclash.apk" ]; then
apk add -s -q --clean-protected --allow-untrusted /tmp/openclash.apk >/dev/null 2>&1
if [ "$?" != "0" ]; then
LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.apk, Please Try to Update Manually!"
if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then
uci -q set openclash.config.config_reload=0
uci -q commit openclash
/etc/init.d/openclash restart >/dev/null 2>&1 &
else
SLOG_CLEAN
fi
del_lock
exit 0
fi
fi
fi
LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..."
cat > /tmp/openclash_update.sh <<"EOF"
#!/bin/sh
START_LOG="/tmp/openclash_start.log"
Expand Down Expand Up @@ -133,7 +148,7 @@ LOG_OUT "Installing The New Version, Please Do Not Refresh The Page or Do Other
if [ -x "/bin/opkg" ]; then
opkg install /tmp/openclash.ipk
elif [ -x "/usr/bin/apk" ]; then
apk add --allow-untrusted /tmp/openclash.apk
apk add -q --clean-protected --allow-untrusted /tmp/openclash.apk
fi
if [ -x "/bin/opkg" ]; then
if [ "$?" != "0" ] || [ -z "$(opkg info *openclash |grep Installed-Time)" ]; then
Expand All @@ -151,7 +166,7 @@ if [ -x "/bin/opkg" ]; then
fi
elif [ -x "/usr/bin/apk" ]; then
if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash 2>/dev/null |grep 'installed')" ]; then
apk add --allow-untrusted /tmp/openclash.apk
apk add -q --clean-protected --allow-untrusted /tmp/openclash.apk
fi
if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash 2>/dev/null |grep 'installed')" ]; then
rm -rf /tmp/openclash.apk >/dev/null 2>&1
Expand Down

0 comments on commit eb716c1

Please sign in to comment.