You've already forked Tricky-Addon-Update-Target-List
mirror of
https://github.com/KOWX712/Tricky-Addon-Update-Target-List.git
synced 2025-09-06 06:37:09 +00:00
opt code
- ensure auto install use latest ksuwebui standalone.
This commit is contained in:
+40
-43
@@ -3,70 +3,67 @@
|
||||
###########################################
|
||||
|
||||
MODPATH="/data/adb/modules/.TA_utl"
|
||||
COMPATH="$MODPATH/common"
|
||||
ORG_PATH="$PATH"
|
||||
TMP_DIR="$MODPATH/common/tmp"
|
||||
SCRIPT_DIR="/data/adb/tricky_store"
|
||||
URL="https://github.com/5ec1cff/KsuWebUIStandalone/releases/download/v1.0/KsuWebUI-1.0-34-release.apk"
|
||||
APK_DIR="$COMPATH/tmp"
|
||||
BBPATH="/data/adb/magisk/busybox \
|
||||
/data/adb/ksu/bin/busybox \
|
||||
/data/adb/ap/bin/busybox \
|
||||
/data/adb/modules/busybox-ndk/system/*/busybox"
|
||||
APK_PATH="$TMP_DIR/base.apk"
|
||||
|
||||
check_wget() {
|
||||
for path in $BBPATH; do
|
||||
[ -f "$path" ] && BUSYBOX="$path" && break
|
||||
done
|
||||
if ! command -v wget >/dev/null || grep -q "wget-curl" "$(command -v wget)"; then
|
||||
if [ -n "$BUSYBOX" ]; then
|
||||
wget() { "$BUSYBOX" wget "$@"; }
|
||||
abort() {
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
download() {
|
||||
local type=${1#--}
|
||||
local url=$2
|
||||
local output=$3
|
||||
|
||||
PATH=/data/adb/magisk:/data/data/com.termux/files/usr/bin:$PATH
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
if [ "$type" = "output" ]; then
|
||||
timeout 10 curl -Lo "$output" "$url"
|
||||
else
|
||||
exit 1
|
||||
timeout 2 curl -s "$url"
|
||||
fi
|
||||
else
|
||||
if [ "$type" = "output" ]; then
|
||||
timeout 10 busybox wget --no-check-certificate -qO "$output" "$url"
|
||||
else
|
||||
timeout 2 busybox wget --no-check-certificate -qO- "$url"
|
||||
fi
|
||||
fi
|
||||
PATH="$ORG_PATH"
|
||||
}
|
||||
|
||||
get_webui() {
|
||||
echo "- Downloading the WebUI APK..."
|
||||
check_wget
|
||||
if ! wget --no-check-certificate -P "$APK_DIR" "$URL"; then
|
||||
echo "! Error: APK download failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "- Download complete."
|
||||
APK_PATH=$(find "$APK_DIR" -type f -name "*.apk" | head -n 1)
|
||||
if [ -z "$APK_PATH" ]; then
|
||||
echo "! Error: No APK file found in $APK_DIR."
|
||||
exit 1
|
||||
fi
|
||||
echo "- Downloading KSU WebUI Standalone..."
|
||||
RESPONSE=$(download --fetch "https://api.github.com/repos/5ec1cff/KsuWebUIStandalone/releases/latest")
|
||||
URL=$(echo "$RESPONSE" | grep -o '"browser_download_url": "[^"]*"' | cut -d '"' -f 4)
|
||||
download --output "$URL" "$APK_PATH" || abort "! Error: APK download failed, please check your internet connection."
|
||||
|
||||
echo "- Installing..."
|
||||
if ! pm install -r "$APK_PATH" >/dev/null 2>&1; then
|
||||
echo "! Error: APK installation failed."
|
||||
pm install -r "$APK_PATH" || {
|
||||
rm -f "$APK_PATH"
|
||||
exit 1
|
||||
fi
|
||||
abort "! Error: APK installation failed."
|
||||
}
|
||||
|
||||
echo "- Done."
|
||||
rm -f "$APK_PATH"
|
||||
|
||||
echo "- Launching..."
|
||||
if ! am start -n "io.github.a13e300.ksuwebui/.WebUIActivity" -e id "tricky_store"; then
|
||||
echo "! Error: WebUI launch failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "- Application launched successfully."
|
||||
echo "- Launching WebUI..."
|
||||
am start -n "io.github.a13e300.ksuwebui/.WebUIActivity" -e id "tricky_store" || abort "! Error: WebUI launch failed."
|
||||
}
|
||||
|
||||
# Lunch KSUWebUI standalone or MMRL, install KSUWebUI standalone if both are not installed
|
||||
if pm list packages | grep -q "io.github.a13e300.ksuwebui"; then
|
||||
# Launch KSUWebUI standalone or MMRL, install KSUWebUI standalone if both are not installed
|
||||
if pm path io.github.a13e300.ksuwebui >/dev/null 2>&1; then
|
||||
echo "- Launching WebUI in KSUWebUIStandalone..."
|
||||
am start -n "io.github.a13e300.ksuwebui/.WebUIActivity" -e id "tricky_store"
|
||||
elif pm list packages | grep -q "com.dergoogler.mmrl"; then
|
||||
elif pm path com.dergoogler.mmrl >/dev/null 2>&1; then
|
||||
echo "- Launching WebUI in MMRL WebUI..."
|
||||
am start -n "com.dergoogler.mmrl/.ui.activity.webui.WebUIActivity" -e MOD_ID "tricky_store"
|
||||
else
|
||||
echo "- Installing KSU WebUI..."
|
||||
echo "! No WebUI app found"
|
||||
get_webui
|
||||
fi
|
||||
|
||||
echo "- WebUI launched successfully."
|
||||
Reference in New Issue
Block a user