Files
backup_script/tools/core/updater.sh
2026-04-29 20:08:41 +08:00

574 lines
25 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/system/bin/sh
# module: updater.sh
backup_wifi() {
[[ ! -d $1 ]] && mkdir -p "$1"
if [[ -d $1 ]]; then
echoRgb "備份wifi密碼"
rm -rf "$1"/*
app_process /system/bin com.xayah.dex.NetworkUtil saveNetworks>"$1/wifi.json"
echo_log "wifi備份"
fi
}
recover_wifi() {
if [[ -d $1 ]]; then
if [[ -f $1/wifi.json ]]; then
echoRgb "恢復wifi密碼"
app_process /system/bin com.xayah.dex.NetworkUtil restoreNetworks "$1/wifi.json"
echo_log "wifi恢復"
else
echoRgb "wifi.json遺失"
fi
else
echoRgb "$1不存在 wifi無法恢復" "0"
fi
}
Rename_script () {
HT="${HT:=0}"
find "$path_hierarchy" -maxdepth 3 -name "*.sh" -type f -not -name "tools.sh" | sort | while read ; do
MODDIR_NAME="${REPLY%/*}"
FILE_NAME="${REPLY##*/}"
if [[ -f ${REPLY%/*}/app_details.json || -f ${REPLY%/*}/app_details ]]; then
if [[ $FILE_NAME = backup.sh ]]; then
touch_shell "1" "$REPLY"
elif [[ $FILE_NAME = recover.sh ]]; then
touch_shell "3" "$REPLY"
fi
else
if [[ -d ${REPLY%/*}/tools ]]; then
if [[ $FILE_NAME = start.sh ]]; then
[[ -f ${REPLY%/*}/backup_settings.conf ]] && touch_shell "0" "$REPLY"
[[ -f ${REPLY%/*}/restore_settings.conf ]] && touch_shell "2" "$REPLY"
fi
fi
HT=$((HT + 1))
fi
done
unset HT
}
touch_shell () {
unset conf_path MODDIR_Path
case $1 in
0)
MODDIR_Path='${0%/*}'
MODDIR_Path1="$MODDIR_Path"
conf_path='${0%/*}/backup_settings.conf' ;;
1)
MODDIR_Path='${0%/*/*/*}'
MODDIR_Path1="$MODDIR_Path"
conf_path='${0%/*/*/*}/backup_settings.conf' ;;
2)
MODDIR_Path='${0%/*}'
MODDIR_Path1="$MODDIR_Path"
conf_path='${0%/*}/restore_settings.conf' ;;
3)
MODDIR_Path='${0%/*/*}'
MODDIR_Path1='${0%/*}'
conf_path='${0%/*/*}/restore_settings.conf' ;;
esac
echo "#!/system/bin/sh
if [ -f \"$MODDIR_Path/tools/tools.sh\" ]; then
MODDIR=\"$MODDIR_Path1\"
conf_path=\"$conf_path\"
[ ! -f \"$conf_path\" ] && . \"$MODDIR_Path/tools/tools.sh\"
else
echo \"$MODDIR_Path/tools/tools.sh遺失\"
fi
. \"$MODDIR_Path/tools/tools.sh\" | tee \"\${0%/*}/log_\$(date +%Y-%m-%d_%H-%M).txt\""> "$2"
}
update_script() {
[[ $zipFile = "" ]] && zipFile="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f 2>/dev/null)"
if [[ $zipFile != "" ]]; then
case $(echo "$zipFile" | wc -l) in
1)
if [[ $(unzip -l "$zipFile" | awk '{print $4}' | egrep -o "^backup_settings.conf$") != "" ]]; then
unzip -o "$zipFile" -j "tools/tools.sh" -d "$MODDIR" &>/dev/null
if [[ -f $MODDIR/tools.sh ]]; then
if [[ $(expr "$(echo "$backup_version" | tr -d "a-zA-Z")" \> "$(awk '/backup_version/{print $1}' "$MODDIR/tools.sh" | cut -f2 -d '=' | head -1 | sed 's/\"//g' | tr -d "a-zA-Z")") -eq 0 ]]; then
shell_language="$(awk -F= '/^shell_language=/ {gsub(/"/, "", $2); print $2}' "$MODDIR/tools.sh")"
case $MODDIR in
*Backup_*)
if [[ -f $MODDIR/app_details.json ]]; then
echoRgb "請在${MODDIR%/*}更新腳本" "0"
rm -rf "$MODDIR/tools.sh"
exit 2
fi ;;
esac
echoRgb "$zipFile更新"
if [[ -d $path_hierarchy/tools ]]; then
mv "$path_hierarchy/tools" "$TMPDIR"
[[ -d $TMPDIR/tools ]] && {
unzip -o "$zipFile" tools/* -d "$path_hierarchy" | sed 's/inflating/釋放/g ; s/creating/創建/g ; s/Archive/解壓縮/g'
echo_log "解壓縮${zipFile##*/}"
if [[ $result = 0 ]]; then
if [[ $shell_language != $Script_target_language ]]; then
echoRgb "腳本語言為$shell_language....轉換為$Script_target_language中,請稍後等待轉換...."
ts <"$path_hierarchy/tools/Device_List">temp && cp temp "$path_hierarchy/tools/Device_List" && rm temp
echo_log "$path_hierarchy/tools/Device_List翻譯"
ts <"$path_hierarchy/tools/tools.sh">temp && cp temp "$path_hierarchy/tools/tools.sh" && rm temp && sed "s/shell_language=\"$shell_language\"/shell_language=\"$Script_target_language\"/g" "$path_hierarchy/tools/tools.sh" > temp && cp temp "$path_hierarchy/tools/tools.sh" && rm temp
echo_log "$path_hierarchy/tools/tools.sh翻譯"
HT=1
fi
update_backup_settings_conf>"$path_hierarchy/backup_settings.conf"
ts <"$path_hierarchy/backup_settings.conf">temp && cp temp "$path_hierarchy/backup_settings.conf" && rm temp
echo_log "$path_hierarchy/backup_settings.conf翻譯"
echo "$find_tools_path" | while read; do
if [[ $REPLY != $path_hierarchy/tools ]]; then
rm -rf "$REPLY"
cp -r "$path_hierarchy/tools" "${REPLY%/*}"
update_Restore_settings_conf>"${REPLY%/*}/restore_settings.conf"
ts <"${REPLY%/*}/restore_settings.conf">temp && cp temp "${REPLY%/*}/restore_settings.conf" && rm temp
echo_log "${REPLY%/*}/restore_settings.conf翻譯"
fi
done
Rename_script
if [[ $Output_path != "" ]]; then
[[ ${Output_path: -1} = / ]] && Output_path="${Output_path%?}"
if [[ ${Output_path:0:1} != / ]]; then
update_path="$MODDIR/$Output_path/Backup_${Compression_method}_$user"
else
update_path="$Output_path/Backup_${Compression_method}_$user"
fi
rm -rf "$update_path/tools"
cp -r "$path_hierarchy/tools" "$update_path"
echoRgb "$update_path/tools已經更新完成"
fi
else
mv "$TMPDIR/tools" "$MODDIR"
fi
rm -rf "$TMPDIR"/* "$zipFile" "$MODDIR/tools.sh"
echoRgb "更新完成 請重新執行腳本" "2"
exit 0
} || echoRgb "tools移動到TMPDIR失敗" "0"
fi
else
echoRgb "${zipFile##*/}版本低於當前版本,自動刪除" "0"
rm -rf "$zipFile" "$path_hierarchy/tools.sh"
fi
else
rm -rf "$zipFile"
unset zipFile
fi
fi ;;
*)
echoRgb "錯誤 請刪除當前目錄多餘zip\n -保留一個最新的數據備份.zip\n -下列為當前目錄zip\n$zipFile" "0"
exit 1 ;;
esac
fi
unset NAME
}
Check_archive() {
starttime1="$(date -u "+%s")"
error_log="$TMPDIR/error_log"
rm -rf "$error_log"
FIND_PATH="$(find "$1" -maxdepth 3 -name "*.tar*" -type f 2>/dev/null | sort)"
i=1
r="$(find "$MODDIR" -maxdepth 2 -name "app_details.json" -type f 2>/dev/null | wc -l)"
find "$MODDIR" -maxdepth 2 -name "app_details.json" -type f 2>/dev/null | sort | while read; do
REPLY="${REPLY%/*}"
echoRgb "校驗第$i/$r個資料夾 剩下$((r - i))" "3"
echoRgb "校驗:${REPLY##*/}"
find "$REPLY" -maxdepth 1 -name "*.tar*" -type f 2>/dev/null | sort | while read; do
Validation_file "$REPLY"
[[ $result != 0 ]] && echo "$REPLY">>"$error_log"
done
echoRgb "$((i * 100 / r))%"
i=$((i + 1)); nskg=$((nskg + 1))
done
endtime 1
[[ -f $error_log ]] && echoRgb "以下為失敗的檔案\n $(cat "$error_log")" || echoRgb "恭喜~~全數校驗通過"
rm -rf "$error_log"
}
get_name(){
txt="$MODDIR/appList.txt"
txt="${txt/'/storage/emulated/'/'/data/media/'}"
txt2="$MODDIR/mediaList.txt"
if [[ $1 = Apkname ]]; then
rm -rf "$txt" "$txt2"
echoRgb "列出全部資料夾內應用名與自定義目錄壓縮包名稱" "3"
fi
rgb_a=118
user="$(echo "${0%}" | sed 's/.*\/Backup_zstd_\([0-9]*\).*/\1/')"
Apk_info="$(pm list packages --user "$user" | cut -f2 -d ':' | egrep -v 'ice.message|com.topjohnwu.magisk' | sort -u)"
if [[ $Apk_info != "" ]]; then
[[ $Apk_info = *"Failure calling service package"* ]] && Apk_info="$(appinfo "user|system" "pkgName" 2>/dev/null | egrep -v 'ice.message|com.topjohnwu.magisk' | sort -u)"
else
Apk_info="$(appinfo "user|system" "pkgName" 2>/dev/null | egrep -v 'ice.message|com.topjohnwu.magisk' | sort -u)"
fi
[[ $Apk_info = "" ]] && echoRgb "Apk_info變量為空" "0" && exit
starttime1="$(date -u "+%s")"
i=1
while read; do
Folder="${REPLY%/*}"
[[ $rgb_a -ge 229 ]] && rgb_a=118
unset PackageName NAME DUMPAPK ChineseName apk_version Ssaid dataSize userSize obbSize
if [[ -f $Folder/app_details.json ]]; then
ChineseName="$(jq -r 'to_entries[] | select(.key != null).key' "$Folder/app_details.json" | head -n 1)"
PackageName="$(jq -r '.[] | select(.PackageName != null).PackageName' "$Folder/app_details.json")"
if [[ -f $Folder/Permissions ]]; then
unset Permissions
. "$Folder/Permissions"
jq --arg packageName "$ChineseName" --argjson permissions "$(echo "$Permissions" | jq -nR '[inputs | select(length>0) | split(" ") | {(.[0]): .[-1]}] | add')" '.[$packageName] |= . + {permissions: $permissions}' "$Folder/app_details.json" > "$TMPDIR/temp.json" && cp "$TMPDIR/temp.json" "$Folder/app_details.json" && rm "$Folder/Permissions" "$TMPDIR/temp.json" && echoRgb "更新$Folder/app_details.json"
fi
else
if [[ -f $Folder/app_details ]]; then
. "$Folder/app_details" &>/dev/null
extra_content="{
\"$ChineseName\": {
\"PackageName\": \"$PackageName\",
\"apk_version\": \"$apk_version\",
\"Ssaid\": \"$Ssaid\"
},
\"data\": {
\"Size\": \"$dataSize\"
},
\"obb\": {
\"Size\": \"$obbSize\"
},
\"user\": {
\"Size\": \"$userSize\"
}
}"
echo "{\n}">"$Folder/app_details.json"
jq --argjson new_content "$extra_content" '. += $new_content' "$Folder/app_details.json" > "$TMPDIR/temp.json" && cp "$TMPDIR/temp.json" "$Folder/app_details.json" && rm "$TMPDIR/temp.json" "$Folder/app_details"
fi
fi
if [[ $PackageName = "" || $ChineseName = "" ]]; then
echoRgb "${Folder##*/}包名獲取失敗,解壓縮獲取包名中..." "0"
rm -rf "$TMPDIR"/*
case ${REPLY##*.} in
zst) tar -I zstd -xmpf "$REPLY" -C "$TMPDIR" --wildcards --no-anchored 'base.apk' ;;
tar) tar -xmpf "$REPLY" -C "$TMPDIR" --wildcards --no-anchored 'base.apk' ;;
*)
echoRgb "${REPLY##*/} 壓縮包不支持解壓縮" "0"
Set_back_1
;;
esac
echo_log "${REPLY##*/}解壓縮"
if [[ $result = 0 ]]; then
if [[ -f $TMPDIR/base.apk ]]; then
DUMPAPK="$(appinfo3 "$TMPDIR/base.apk")"
if [[ $DUMPAPK != "" ]]; then
app=($DUMPAPK $DUMPAPK)
PackageName="${app[1]}"
ChineseName="${app[2]}"
rm -rf "$TMPDIR"/*
else
echoRgb "appinfo輸出失敗" "0"
fi
fi
fi
fi
if [[ $PackageName != "" && $ChineseName != "" ]]; then
if [[ $(echo "$Apk_info" | awk -v pkg="$PackageName" '$1 == pkg {print $1}') = "" ]]; then
echoRgb "$ChineseName已經不存在$user使用者中"
if [[ $delete_app = "" ]]; then
delete_app="$ChineseName $PackageName"
else
delete_app="$delete_app\n$ChineseName $PackageName"
fi
fi
case $1 in
Apkname)
[[ -f $Folder/${PackageName}.sh ]] && rm -rf "$Folder/${PackageName}.sh"
[[ ! -f $Folder/recover.sh ]] && touch_shell "3" "$Folder/recover.sh"
[[ ! -f $Folder/backup.sh ]] && touch_shell "1" "$Folder/backup.sh"
echoRgb "$i:$ChineseName $PackageName"
if [[ $TMPTXT = "" ]]; then
TMPTXT="#不需要恢復還原的應用請在開頭使用#注釋 比如:#酷安 com.coolapk.market\n$ChineseName $PackageName"
else
TMPTXT="$TMPTXT\n$ChineseName $PackageName"
fi
i=$((i + 1)) ;;
convert)
if [[ ${Folder##*/} = $PackageName ]]; then
DIR_NAME="${Folder%/*}/$ChineseName"
echoRgb "${Folder##*/} > $ChineseName"
else
DIR_NAME="${Folder%/*}/$PackageName"
echoRgb "${Folder##*/} > $PackageName"
fi
if [[ -d $DIR_NAME ]]; then
i=1
NEW_DIR_NAME="${DIR_NAME}_${i}"
while [[ -d $NEW_DIR_NAME ]]; do
i=$((i + 1))
NEW_DIR_NAME="${DIR_NAME}_${i}"
done
DIR_NAME="$NEW_DIR_NAME"
fi
mv "$Folder" "$DIR_NAME" ;;
esac
fi
rgb_a=$((rgb_a + 1))
done<<<"$(find "$MODDIR" -maxdepth 2 -name "apk.*" -type f 2>/dev/null | sort)"
[[ $TMPTXT != "" ]] && echo "$TMPTXT">"$txt"
if [[ -d $MODDIR/Media ]]; then
echoRgb "存在媒體資料夾" "2"
[[ ! -f $txt2 ]] && echo "#不需要恢復的資料夾請在開頭使用#注釋 比如:#Download" > "$txt2"
find "$MODDIR/Media" -maxdepth 1 -name "*.tar*" -type f 2>/dev/null | while read; do
echoRgb "${REPLY##*/}" && echo "${REPLY##*/}" >> "$txt2"
done
echoRgb "$txt2重新生成" "1"
fi
if [[ $delete_app != "" ]]; then
if [[ $(echo "$delete_app" | awk 'NF != 0 { count++ } END { print count }') != "" ]]; then
echoRgb "列出需要刪除的應用中....\n -$delete_app"
case $Lo in
0|1)
echoRgb "確認列表無誤後音量上刪除,音量下退出腳本編輯列表" "2"
get_version "刪除" "退出腳本" && Delete_App="$branch" ;;
2)
Enter_options "確認列表無誤後輸入1刪除輸入0退出腳本編輯列表" "刪除" "退出腳本" && isBoolean "$parameter" "Delete_App" && Delete_App="$nsx" ;;
esac
if [[ $Delete_App = true ]]; then
echoRgb "警告 即將刪除未安裝應用資料夾,請再三確認後在執行" "0"
i=1
r="$(echo "$delete_app" | awk 'NF != 0 { count++ } END { print count }')"
while [[ $i -le $r ]]; do
name1="$(echo "$delete_app" | sed -e '/^$/d' | sed -n "${i}p" | cut -d' ' -f1)"
name2="$(echo "$delete_app" | sed -e '/^$/d' | sed -n "${i}p" | cut -d' ' -f2)"
Backup_folder="$MODDIR/$name1"
[[ -d $Backup_folder ]] && rm -rf "$Backup_folder"
echo "$(sed -e "s/$name1 $name2//g ; /^$/d" "$txt" 2>/dev/null)" >"$txt"
i=$((i + 1))
done
else
exit 0
fi
fi
fi
chown "$(stat -c '%u:%g' '/data/media/0/Download')" "$txt"
endtime 1
exit 0
}
Getlist() {
case $MODDIR in
/storage/emulated/0/Android/* | /data/media/0/Android/* | /sdcard/Android/*) echoRgb "請勿在$MODDIR內生成列表" "0" && exit 2 ;;
esac
#校驗選填是否正確
case $Lo in
0)
[[ $blacklist_mode != "" ]] && isBoolean "$blacklist_mode" "blacklist_mode" && blacklist_mode="$nsx" || {
echoRgb "選擇黑名單模式\n -音量上不輸出,音量下輸出應用列表" "2"
get_version "不輸出" "輸出應用列表" && blacklist_mode="$branch"
} ;;
1)
if [[ $(echo "$blacklist" | egrep -v '#|' | wc -l) -gt 0 ]]; then
[[ $blacklist_mode = "" ]] && {
echoRgb "選擇黑名單模式\n -音量上不輸出,音量下輸出應用列表" "2"
get_version "不輸出" "輸出應用列表" && blacklist_mode="$branch"
} || isBoolean "$blacklist_mode" "blacklist_mode" && blacklist_mode="$nsx"
fi ;;
2)
[[ $blacklist_mode = "" ]] && {
Enter_options "選擇黑名單模式輸入1不輸出輸入0輸出應用列表" "不輸出" "輸出應用列表" && isBoolean "$parameter" "blacklist_mode" && blacklist_mode="$nsx"
} || {
isBoolean "$blacklist_mode" "blacklist_mode" && blacklist_mode="$nsx"
} ;;
*) echoRgb "$conf_path Lo=$Lo填寫錯誤正確值0 1 2" "0" && exit 2 ;;
esac
txt="$TMPDIR/appList"
[[ -f "$MODDIR/appList.txt" ]] && cat "$MODDIR/appList.txt" >"$txt"
[[ ! -f $txt ]] && echo '#不需要備份的應用請在開頭使用#注釋 比如:#酷安 com.coolapk.market忽略安裝包和數據\n#不需要備份數據的應用請在開頭使用!注釋 比如:!酷安 com.coolapk.market僅忽略數據' >"$txt"
echoRgb "請勿關閉腳本,等待提示結束"
rgb_a=118
starttime1="$(date -u "+%s")"
echoRgb "提示! 腳本默認會屏蔽預裝應用 如需備份請添加預裝應用白名單" "0"
Apk_info="$(appinfo "system|user|xposed" "label|pkgName|flag" | egrep -v 'ice.message|com.topjohnwu.magisk' | tr '/:' '_')"
xposed_name="$(echo "$Apk_info" | awk '$3 == "xposed" {print $2}')"
TARGET_PACKAGES="$(echo "$system" | paste -sd'|' - | sed 's/^|//')"
Pre_installed_apps="$(echo "$Apk_info" | awk '$3 == "system" {print $1, $2}' | egrep -w "$TARGET_PACKAGES")"
Apk_info="$(echo "$(echo "$Apk_info" | awk '$3 != "system" {print $1, $2}')\n$Pre_installed_apps" | sort -u)"
[[ $Apk_info = "" ]] && {
echoRgb "appinfo輸出失敗,請截圖畫面回報作者" "0"
exit 2 ; } || Apk_info2="$(echo "$Apk_info" | cut -d' ' -f2)"
Apk_Quantity="$(echo "$Apk_info" | wc -l)"
LR="1"
echoRgb "列出第三方應用......." "2"
i="0"
rc="0"
rd="0"
Q="0"
rb="0"
Output_list() {
if [[ $(cat "$txt" | cut -f2 -d ' ' | egrep -w "^${app_1[1]}$") != ${app_1[1]} ]]; then
[[ $REPLY2 = "" ]] && add_entry "${app_1[2]}" "${app_1[1]}" "$(grep -w "${app_1[2]}" "$txt")" || add_entry "${app_1[2]}" "${app_1[1]}" "$REPLY2"
case ${app_1[1]} in
*oneplus*|*miui*|*xiaomi*|*oppo*|*flyme*|*meizu*|com.android.soundrecorder|com.mfashiongallery.emag|com.mi.health|*coloros*|com.android.soundrecorder|com.duokan.phone.remotecontroller|com.android.calendar|com.android.deskclock|com.android.calendar|com.android.deskclock|com.google.android.safetycore|com.google.android.contactkeys|com.google.android.apps.messaging|com.google.android.calendar)
if [[ $(echo "$xposed_name" | egrep -w "${app_1[1]}$") = ${app_1[1]} ]]; then
echoRgb "$((i+1)):$app_name為Xposed模塊 進行添加" "0"
if [[ $REPLY2 = "" ]]; then
REPLY2="$REPLY" && [[ $tmp = "" ]] && tmp="1"
else
REPLY2="$REPLY2\n$REPLY" && [[ $tmp = "" ]] && tmp="1"
fi
i=$((i + 1)); rd=$((rd + 1))
else
if [[ $(echo "$whitelist" | egrep -w "^${app_1[1]}$") = ${app_1[1]} ]]; then
if [[ $REPLY2 = "" ]]; then
REPLY2="$REPLY" && [[ $tmp = "" ]] && tmp="1"
else
REPLY2="$REPLY2\n$REPLY" && [[ $tmp = "" ]] && tmp="1"
fi
echoRgb "$((i+1)):$app_name ${app_1[1]}($rgb_a)"
i=$((i + 1))
else
echoRgb "$app_name 預裝應用 忽略輸出" "0"
if [[ $REPLY2 = "" ]]; then
REPLY2="#$REPLY" && [[ $tmp = "" ]] && tmp="1"
else
REPLY2="$REPLY2\n#$REPLY" && [[ $tmp = "" ]] && tmp="1"
fi
rc=$((rc + 1))
fi
fi
;;
*)
if [[ $REPLY2 = "" ]]; then
REPLY2="$REPLY" && [[ $tmp = "" ]] && tmp="1"
else
REPLY2="$REPLY2\n$REPLY" && [[ $tmp = "" ]] && tmp="1"
fi
if [[ $(echo "$xposed_name" | egrep -w "${app_1[1]}$") = ${app_1[1]} ]]; then
echoRgb "$((i+1)):Xposed: $app_name ${app_1[1]}($rgb_a)"
rd=$((rd + 1))
else
echoRgb "$((i+1)):$app_name ${app_1[1]}($rgb_a)"
fi
i=$((i + 1))
;;
esac
else
Q=$((Q + 1))
fi
}
[[ $(echo "$blacklist" | egrep -v '#|') != "" ]] && NZK=1
echo "$Apk_info" | sed 's/[\/:()\[\]\-!]//g' | while read; do
[[ $rgb_a -ge 229 ]] && rgb_a=118
app_1=($REPLY $REPLY)
if [[ $NZK = 1 ]]; then
if [[ $(echo "$blacklist" | egrep -w "^${app_1[1]}$") != ${app_1[1]} ]]; then
Output_list
else
if [[ $blacklist_mode = false ]]; then
Output_list
rb=$((rb + 1))
else
echoRgb "${app_1[2]}黑名單應用 不輸出" "0"
rb=$((rb + 1))
fi
fi
else
Output_list
fi
if [[ $LR = $Apk_Quantity ]]; then
echo "$REPLY2">>"$txt"
if [[ $(cat "$txt" | wc -l | awk '{print $1-2}') -lt $i ]]; then
rm -rf "$txt"
echoRgb "\n -輸出異常 請聯繫作者解決" "0"
exit 1
fi
echoRgb "已經將預裝應用輸出至appList.txt並注釋# 需要備份則去掉#" "0"
[[ $tmp != "" ]] && echoRgb "\n -第三方apk數量=\"$Apk_Quantity\"\n -已過濾=\"$rc\"\n -xposed=\"$rd\"\n -黑名單應用=\"$rb\"\n -存在列表中=\"$Q\"\n -輸出=\"$i\""
fi
rgb_a=$((rgb_a + 1)); LR=$((LR + 1))
done
if [[ -f $txt ]]; then
while read -r ; do
if [[ $(echo "$REPLY" | sed -E 's/^[ \t]*//; /^[ \t]*[#!]/d') != "" ]]; then
app=($REPLY $REPLY)
if [[ ${app[1]} != "" && ${app[2]} != "" ]]; then
if [[ $(echo "$Apk_info2" | awk -v pkg="${app[1]}" '$1 == pkg {print $1}') != "" ]]; then
[[ $Tmplist = "" ]] && Tmplist='#不需要備份的應用請在開頭使用#注釋 比如:#酷安 com.coolapk.market忽略安裝包和數據\n#不需要備份數據的應用請在開頭使用!注釋 比如:!酷安 com.coolapk.market僅忽略數據'
Tmplist="$Tmplist\n$REPLY"
else
echoRgb "$REPLY不存在系統,從列表中刪除" "0"
fi
fi
else
Tmplist="$Tmplist\n$REPLY"
fi
done < "$txt"
[[ $Tmplist != "" ]] && echo "$Tmplist" | sed -e '/^$/d' | sort>"$txt"
fi
wait
endtime 1
cat "$txt">"$MODDIR/appList.txt" && rm "$txt"
chown "$(stat -c '%u:%g' '/data/media/0/Download')" "$MODDIR/appList.txt"
echoRgb "輸出包名結束 請查看$MODDIR/appList.txt"
}
}
Device_List() {
URL="https://raw.githubusercontent.com/KHwang9883/MobileModels/refs/heads/master/brands"
rm -rf "$tools_path/Device_List"
for i in $(echo "xiaomi\nxiaomi_en\nsamsung\nsamsung_global\nasus\nBlack_Shark\nBlack_Shark_en\ngoogle\nLenovo\nMEIZU\nMEIZU_en\nMotorola\nNokia\nnothing\nnubia\nOnePlus\nOnePlus_en\nSony\nrealme\nrealme_en\nvivo\nvivo_en\noppo\noppo_en"); do
echoRgb "獲取品牌$i"
case $i in
xiaomi) Brand_URL="$URL/xiaomi.md" ;;
xiaomi_en) Brand_URL="$URL/xiaomi_en.md" ;;
samsung) Brand_URL="$URL/samsung_cn.md" ;;
samsung_global) Brand_URL="$URL/samsung_global_en.md" ;;
asus) Brand_URL="$URL/asus.md" ;;
Black_Shark) Brand_URL="$URL/blackshark.md" ;;
Black_Shark_en) Brand_URL="$URL/blackshark_en.md" ;;
google) Brand_URL="$URL/google.md" ;;
Lenovo) Brand_URL="$URL/lenovo.md" ;;
MEIZU) Brand_URL="$URL/meizu.md" ;;
MEIZU_en) Brand_URL="$URL/meizu_en.md" ;;
Motorola) Brand_URL="$URL/motorola.md" ;;
Nokia) Brand_URL="$URL/nokia.md" ;;
nothing) Brand_URL="$URL/nothing.md" ;;
nubia) Brand_URL="$URL/nubia.md" ;;
OnePlus) Brand_URL="$URL/oneplus.md" ;;
OnePlus_en) Brand_URL="$URL/oneplus_en.md" ;;
Sony) Brand_URL="$URL/sony_cn.md" ;;
realme) Brand_URL="$URL/realme_cn.md" ;;
realme_en) Brand_URL="$URL/realme_global_en.md" ;;
vivo) Brand_URL="$URL/vivo_cn.md" ;;
vivo_en) Brand_URL="$URL/vivo_global_en.md" ;;
oppo) Brand_URL="$URL/oppo_cn.md" ;;
oppo_en) Brand_URL="$URL/oppo_global_en.md" ;;
esac
if [[ ! -e $tools_path/Device_List ]]; then
down "$Brand_URL" | grep -oE '`[^`]+`:[^`]*' | sed -E 's/: /:/g' | sed -E 's/`([^`]+)`:(.*)/"\1" "\2"/'>"$tools_path/Device_List"
else
down "$Brand_URL" | grep -oE '`[^`]+`:[^`]*' | sed -E 's/: /:/g' | sed -E 's/`([^`]+)`:(.*)/"\1" "\2"/' | while read ; do
unset model
model="$(echo "$REPLY" | awk -F'"' '{print $2}')"
if [[ $(egrep -w "$model" "$tools_path/Device_List" | awk -F'"' '{print $2}') != $model ]]; then
echo "$REPLY">>"$tools_path/Device_List"
else
echo "$(egrep -w "$model" "$tools_path/Device_List" | awk -F'"' '{print $2}') = $model"
fi
done
fi
done
if [[ -e $tools_path/Device_List ]]; then
if [[ $(ls -l "$tools_path/Device_List" | awk '{print $5}') -gt 1 ]]; then
[[ $shell_language = zh-TW ]] && ts <"$tools_path/Device_List">temp && cp temp "$tools_path/Device_List" && rm temp
echoRgb "已下載機型列表在$tools_path/Device_List"
else
echoRgb "下載機型失敗"
fi
else
echoRgb "下載機型失敗"
fi
}
wifi() {
backup_path
[[ ! -d $Backup/tools ]] && cp -r "$tools_path" "$Backup"
[[ ! -f $Backup/start.sh ]] && touch_shell "2" "$Backup/start.sh"
[[ ! -f $Backup/restore_settings.conf ]] && update_Restore_settings_conf>"$Backup/restore_settings.conf"
backup_wifi "$Backup/wifi"
}
dumpname() {
get_name "Apkname"
}
convert() {
get_name "convert"
}
check_file() {
Check_archive "$MODDIR"
}