diff --git a/tools/bin/bin.sh b/tools/bin/bin.sh index 537242c..3a1c41d 100644 --- a/tools/bin/bin.sh +++ b/tools/bin/bin.sh @@ -18,7 +18,7 @@ if [[ -d $(magisk --path 2>/dev/null) ]]; then else echo "Magisk busybox Path does not exist" fi ; export PATH="$PATH" -backup_version="V12.2" +backup_version="V12.3" #設置二進制命令目錄位置 [[ $bin_path = "" ]] && echo "未正確指定bin.sh位置" && exit 2 #bin_path="${bin_path/'/storage/emulated/'/'/data/media/'}" @@ -158,8 +158,152 @@ echo_log() { echoRgb "$1失敗,過世了" "0" ; Print "$1失敗,過世了" ; result=1 fi } -if [[ -f $bin_path/update ]]; then - . "$bin_path/update" +LANG="$(getprop "persist.sys.locale")" +if [[ $LANG != "" ]]; then + case $LANG in + *-TW|*-tw) + echoRgb "系統語系:繁體中文" + Language="https://api.github.com/repos/YAWAsau/backup_script/releases/latest" ;; + *-CN|*-cn) + echoRgb "系統語系:簡體中文" + Language="https://api.github.com/repos/Petit-Abba/backup_script_zh-CN/releases/latest" ;; + * ) + echoRgb "$LANG不支持 默認簡體中文" "0" + Language="https://api.github.com/repos/Petit-Abba/backup_script_zh-CN/releases/latest" ;; + esac else - echoRgb "更新腳本遺失 無法自動檢查更新" "0" -fi \ No newline at end of file + echoRgb "獲取系統語系失敗 默認簡體中文" "0" + Language="https://api.github.com/repos/Petit-Abba/backup_script_zh-CN/releases/latest" +fi +down -s -L "$Language" 2>/dev/null >"$bin_path/json" +Open_apps="$(appinfo -o ands -ta c)" +bn=147 +echoRgb "\n --------------歡迎使用⚡️🤟🐂纸備份--------------\n -當前腳本執行路徑:$MODDIR\n -busybox路徑:$(which busybox)\n -busybox版本:$(busybox | head -1 | awk '{print $2}')\n -appinfo版本:$(appinfo --version)\n -腳本版本:$backup_version\n -設備架構$abi\n -品牌:$(getprop ro.product.brand)\n -設備代號:$(getprop ro.product.device)\n -型號:$(getprop ro.product.model)\n -Android版本:$(getprop ro.build.version.release)\n -SDK:$(getprop ro.build.version.sdk)\n -終端:$Open_apps" +bn=195 +if [[ $script != "" && $(pgrep -f "$script" | grep -v grep | wc -l) -ge 2 ]]; then + echoRgb "檢測到進程殘留,請重新執行腳本 已銷毀進程" "0" + pgrep -f "$script" | grep -v grep | while read i; do + [[ $i != "" ]] && kill -9 " $i" >/dev/null + done +fi +if [[ $(pm path ice.message) = "" ]]; then + echoRgb "未安裝toast 開始安裝" "0" + cp -r "${bin_path%/*}/apk"/*.apk "$TMPDIR" && pm install --user 0 -r "$TMPDIR"/*.apk &>/dev/null && rm -rf "$TMPDIR"/* + [[ $? = 0 ]] && echoRgb "安裝toast成功" "1" || echoRgb "安裝toast失敗" "0" +fi +zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)" +#sed -r -n 's/.*"tag_name": *"(.*)".*/\1/p' +#sed -r -n 's/.*"browser_download_url": *"(.*-linux64\..*\.so\.bz2)".*/\1/p' +if [[ -f $bin_path/json && $(cat "$bin_path/json") != "" ]]; then + tag="$(cat "$bin_path/json" | sed -r -n 's/.*"tag_name": *"(.*)".*/\1/p')" + download="$(cat "$bin_path/json" | sed -r -n 's/.*"browser_download_url": *"(.*.zip)".*/\1/p')" + if [[ $tag != "" ]]; then + if [[ $backup_version != $tag ]]; then + echoRgb "發現新版本 從GitHub更新 版本:$tag\n -更新日誌:\n$(cat "$bin_path/json" | sed -r -n 's/.*"body": *"(.*)".*/\1/p')" + down -s -L -o "$MODDIR/$tag.zip" "https://gh.api.99988866.xyz/$download" + echo_log "下載${download##*/}" + if [[ $result = 0 ]]; then + zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)" + GitHub="true" + else + echoRgb "請手動將備份腳本壓縮包放置在\n -$MODDIR後再次執行腳本進行更新" "0" + fi + else + echoRgb "本地版本:$backup_version 線上版本:$tag 版本一致無須更新" + fi + fi + rm -rf "$bin_path/json" +else + echoRgb "更新獲取失敗" "0" +fi +if [[ $zippath != "" ]]; then + case $(echo "$zippath" | wc -l) in + 1) + [[ $GitHub != true ]] && echoRgb "從$zippath更新" + if [[ $(unzip -l "$zippath" | awk '{print $4}' | grep -oE "^backup_settings.conf$") = "" ]]; then + echoRgb "${zippath##*/}並非指定的備份zip,請刪除後重新放置\n -何謂更新zip? 就是GitHub release頁面下載的zip" "0" + else + cp -r "$tools_path" "$TMPDIR" && rm -rf "$tools_path" + find "$MODDIR" -maxdepth 3 -name "*.sh" -type f -exec rm -rf {} \; + unzip -o "$zippath" -d "$MODDIR" + echo_log "解壓縮${zippath##*/}" + if [[ $result = 0 ]]; then + case $MODDIR in + *Backup_*) + if [[ -f $MODDIR/app_details ]]; then + mv "$MODDIR/tools" "${MODDIR%/*}" + echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+外部tools目錄" + cp -r "$tools_path/script/Get_DirName" "${MODDIR%/*}/掃描資料夾名.sh" + cp -r "$tools_path/script/restore" "${MODDIR%/*}/還原備份.sh" + [[ -d ${MODDIR%/}/媒體 ]] && cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh" + . "$MODDIR/app_details" + if [[ $PackageName != "" ]]; then + cp -r "$tools_path/script/restore2" "$MODDIR/還原備份.sh" + else + cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh" + fi + if [[ -d ${MODDIR%/*/*}/tools && -f ${MODDIR%/*/*}/備份應用.sh ]]; then + echoRgb "更新${MODDIR%/*/*}/tools與備份相關腳本" + rm -rf "${MODDIR%/*/*}/tools" + find "${MODDIR%/*/*}" -maxdepth 1 -name "*.sh" -type f -exec rm -rf {} \; + mv "$MODDIR/backup_settings.conf" "$MODDIR/備份應用.sh" "$MODDIR/生成應用列表.sh" "${MODDIR%/*/*}" + cp -r "$tools_path" "${MODDIR%/*/*}" + fi + else + echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+tools目錄" + cp -r "$tools_path/script/Get_DirName" "$MODDIR/掃描資料夾名.sh" + cp -r "$tools_path/script/restore" "$MODDIR/還原備份.sh" + [[ -d $MODDIR/媒體 ]] && cp -r "$tools_path/script/restore3" "$MODDIR/媒體/恢復多媒體數據.sh" + find "$MODDIR" -maxdepth 1 -type d | sort | while read; do + if [[ -f $REPLY/app_details ]]; then + unset PackageName + . "$REPLY/app_details" + [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/還原備份.sh" + fi + done + if [[ -d ${MODDIR%/*}/tools && -f ${MODDIR%/*}/備份應用.sh ]]; then + echoRgb "更新${MODDIR%/*}/tools與備份相關腳本" + rm -rf "${MODDIR%/*}/tools" + find "${MODDIR%/*}" -maxdepth 1 -name "*.sh" -type f -exec rm -rf {} \; + mv "$MODDIR/backup_settings.conf" "$MODDIR/備份應用.sh" "$MODDIR/生成應用列表.sh" "${MODDIR%/*}" + cp -r "$tools_path" "${MODDIR%/*}" + fi + fi + rm -rf "$tools_path/script" "$MODDIR/backup_settings.conf" "$MODDIR/備份應用.sh" "$MODDIR/生成應用列表.sh" ;; + *) + if [[ $(find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d) != "" ]]; then + find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d | while read backup_path; do + if [[ -d $backup_path && $backup_path != $MODDIR ]]; then + echoRgb "更新當前目錄下備份相關腳本&tools目錄+${backup_path##*/}內tools目錄+恢復腳本+tools" + cp -r "$tools_path" "$backup_path" && rm -rf "$backup_path/tools/bin/zip" "$backup_path/tools/script" + cp -r "$tools_path/script/restore" "$backup_path/還原備份.sh" + cp -r "$tools_path/script/Get_DirName" "$backup_path/掃描資料夾名.sh" + [[ -d $backup_path/媒體 ]] && cp -r "$tools_path/script/restore3" "$backup_path/媒體/恢復多媒體數據.sh" + find "$MODDIR" -maxdepth 2 -type d | sort | while read; do + if [[ -f $REPLY/app_details ]]; then + unset PackageName + . "$REPLY/app_details" + [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/還原備份.sh" + fi + done + fi + done + else + echoRgb "更新當前${MODDIR##*/}目錄下備份相關腳本+tools目錄" + fi ;; + esac + else + cp -r "$TMPDIR/tools" "$MODDIR" + fi + rm -rf "$TMPDIR"/* + find "$MODDIR" -maxdepth 1 -name "*.zip" -type f -exec rm -rf {} \; + echoRgb "更新完成 請重新執行腳本" "2" && exit + fi ;; + *) + echoRgb "錯誤 請刪除當前目錄多餘zip\n -保留一個最新的數據備份.zip\n -下列為當前目錄zip\n$zippath" "0" && exit 1 ;; + esac +fi +#down -s -L "https://magisk-modules-repo.github.io/submission/modules.json" | jq -r '.modules[] | {id,prop_url,zip_url}' +#down -s -L "https://magisk-modules-repo.github.io/submission/modules.json" | jq -r '.modules[].zip_url' | egrep -w "Ainur_Narsil|riru_lsposed|busybox-ndk|riru_storage_redirect|riru-core|HideNavBar" | while read; do +# down -s -L -o "$MODDIR/${REPLY##*/}" "$REPLY" +#done \ No newline at end of file diff --git a/tools/bin/classes.dex b/tools/bin/classes.dex index 36ea28b..0b953ca 100644 Binary files a/tools/bin/classes.dex and b/tools/bin/classes.dex differ diff --git a/tools/bin/jq b/tools/bin/jq deleted file mode 100644 index e61cfb4..0000000 Binary files a/tools/bin/jq and /dev/null differ diff --git a/tools/bin/update b/tools/bin/update deleted file mode 100644 index ec4a969..0000000 --- a/tools/bin/update +++ /dev/null @@ -1,150 +0,0 @@ -[ "$bin_path" = "" ] && echo "未指定bin_path" && exit -LANG="$(getprop "persist.sys.locale")" -if [[ $LANG != "" ]]; then - case $LANG in - *-TW|*-tw) - echoRgb "系統語系:繁體中文" - Language="https://api.github.com/repos/YAWAsau/backup_script/releases/latest" ;; - *-CN|*-cn) - echoRgb "系統語系:簡體中文" - Language="https://api.github.com/repos/Petit-Abba/backup_script_zh-CN/releases/latest" ;; - * ) - echoRgb "$LANG不支持 默認簡體中文" "0" - Language="https://api.github.com/repos/Petit-Abba/backup_script_zh-CN/releases/latest" ;; - esac -else - echoRgb "獲取系統語系失敗 默認簡體中文" "0" - Language="https://api.github.com/repos/Petit-Abba/backup_script_zh-CN/releases/latest" -fi -down -s -L "$Language" 2>/dev/null >"$bin_path/json" -Open_apps="$(appinfo -o ands -ta c)" -bn=147 -echoRgb "\n --------------歡迎使用⚡️🤟🐂纸備份--------------\n -當前腳本執行路徑:$MODDIR\n -busybox路徑:$(which busybox)\n -busybox版本:$(busybox | head -1 | awk '{print $2}')\n -appinfo版本:$(appinfo --version)\n -腳本版本:$backup_version\n -設備架構$abi\n -品牌:$(getprop ro.product.brand)\n -設備代號:$(getprop ro.product.device)\n -型號:$(getprop ro.product.model)\n -Android版本:$(getprop ro.build.version.release)\n -SDK:$(getprop ro.build.version.sdk)\n -終端:$Open_apps" -bn=195 -if [[ $script != "" && $(pgrep -f "$script" | grep -v grep | wc -l) -ge 2 ]]; then - echoRgb "檢測到進程殘留,請重新執行腳本 已銷毀進程" "0" - pgrep -f "$script" | grep -v grep | while read i; do - [[ $i != "" ]] && kill -9 " $i" >/dev/null - done -fi -if [[ $(pm path ice.message) = "" ]]; then - echoRgb "未安裝toast 開始安裝" "0" - cp -r "${bin_path%/*}/apk"/*.apk "$TMPDIR" && pm install --user 0 -r "$TMPDIR"/*.apk &>/dev/null && rm -rf "$TMPDIR"/* - [[ $? = 0 ]] && echoRgb "安裝toast成功" "1" || echoRgb "安裝toast失敗" "0" -fi -zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)" -#sed -r -n 's/.*"browser_download_url": *"(.*)".*/\1/p' -#sed -r -n 's/.*"browser_download_url": *"(.*-linux64\..*\.so\.bz2)".*/\1/p' -if [[ -f $bin_path/json && $(cat "$bin_path/json") != "" ]]; then - tag="$(cat "$bin_path/json" | jq -r '.tag_name')" - download="$(cat "$bin_path/json" | sed -r -n 's/.*"browser_download_url": *"(.*.zip)".*/\1/p')" - if [[ $tag != "" ]]; then - if [[ $backup_version != $tag ]]; then - echoRgb "發現新版本 從GitHub更新 版本:$tag\n -更新日誌:\n$(cat "$bin_path/json" | jq -r '.body')" - down -s -L -o "$MODDIR/$tag.zip" "https://gh.api.99988866.xyz/$download" - echo_log "下載${download##*/}" - if [[ $result = 0 ]]; then - zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)" - GitHub="true" - else - echoRgb "請手動將備份腳本壓縮包放置在\n -$MODDIR後再次執行腳本進行更新" "0" - fi - else - echoRgb "本地版本:$backup_version 線上版本:$tag 版本一致無須更新" - fi - fi - rm -rf "$bin_path/json" -else - echoRgb "更新獲取失敗" "0" -fi -if [[ $zippath != "" ]]; then - case $(echo "$zippath" | wc -l) in - 1) - [[ $GitHub != true ]] && echoRgb "從$zippath更新" - if [[ $(unzip -l "$zippath" | awk '{print $4}' | grep -oE "^backup_settings.conf$") = "" ]]; then - echoRgb "${zippath##*/}並非指定的備份zip,請刪除後重新放置\n -何謂更新zip? 就是GitHub release頁面下載的zip" "0" - else - cp -r "$tools_path" "$TMPDIR" && rm -rf "$tools_path" - find "$MODDIR" -maxdepth 3 -name "*.sh" -type f -exec rm -rf {} \; - unzip -o "$zippath" -d "$MODDIR" - echo_log "解壓縮${zippath##*/}" - if [[ $result = 0 ]]; then - case $MODDIR in - *Backup_*) - if [[ -f $MODDIR/app_details ]]; then - mv "$MODDIR/tools" "${MODDIR%/*}" - echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+外部tools目錄" - cp -r "$tools_path/script/Get_DirName" "${MODDIR%/*}/掃描資料夾名.sh" - cp -r "$tools_path/script/restore" "${MODDIR%/*}/還原備份.sh" - [[ -d ${MODDIR%/}/媒體 ]] && cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh" - . "$MODDIR/app_details" - if [[ $PackageName != "" ]]; then - cp -r "$tools_path/script/restore2" "$MODDIR/還原備份.sh" - else - cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh" - fi - if [[ -d ${MODDIR%/*/*}/tools && -f ${MODDIR%/*/*}/備份應用.sh ]]; then - echoRgb "更新${MODDIR%/*/*}/tools與備份相關腳本" - rm -rf "${MODDIR%/*/*}/tools" - find "${MODDIR%/*/*}" -maxdepth 1 -name "*.sh" -type f -exec rm -rf {} \; - mv "$MODDIR/backup_settings.conf" "$MODDIR/備份應用.sh" "$MODDIR/生成應用列表.sh" "${MODDIR%/*/*}" - cp -r "$tools_path" "${MODDIR%/*/*}" - fi - else - echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+tools目錄" - cp -r "$tools_path/script/Get_DirName" "$MODDIR/掃描資料夾名.sh" - cp -r "$tools_path/script/restore" "$MODDIR/還原備份.sh" - [[ -d $MODDIR/媒體 ]] && cp -r "$tools_path/script/restore3" "$MODDIR/媒體/恢復多媒體數據.sh" - find "$MODDIR" -maxdepth 1 -type d | sort | while read; do - if [[ -f $REPLY/app_details ]]; then - unset PackageName - . "$REPLY/app_details" - [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/還原備份.sh" - fi - done - if [[ -d ${MODDIR%/*}/tools && -f ${MODDIR%/*}/備份應用.sh ]]; then - echoRgb "更新${MODDIR%/*}/tools與備份相關腳本" - rm -rf "${MODDIR%/*}/tools" - find "${MODDIR%/*}" -maxdepth 1 -name "*.sh" -type f -exec rm -rf {} \; - mv "$MODDIR/backup_settings.conf" "$MODDIR/備份應用.sh" "$MODDIR/生成應用列表.sh" "${MODDIR%/*}" - cp -r "$tools_path" "${MODDIR%/*}" - fi - fi - rm -rf "$tools_path/script" "$MODDIR/backup_settings.conf" "$MODDIR/備份應用.sh" "$MODDIR/生成應用列表.sh" ;; - *) - if [[ $(find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d) != "" ]]; then - find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d | while read backup_path; do - if [[ -d $backup_path && $backup_path != $MODDIR ]]; then - echoRgb "更新當前目錄下備份相關腳本&tools目錄+${backup_path##*/}內tools目錄+恢復腳本+tools" - cp -r "$tools_path" "$backup_path" && rm -rf "$backup_path/tools/bin/zip" "$backup_path/tools/script" - cp -r "$tools_path/script/restore" "$backup_path/還原備份.sh" - cp -r "$tools_path/script/Get_DirName" "$backup_path/掃描資料夾名.sh" - [[ -d $backup_path/媒體 ]] && cp -r "$tools_path/script/restore3" "$backup_path/媒體/恢復多媒體數據.sh" - find "$MODDIR" -maxdepth 2 -type d | sort | while read; do - if [[ -f $REPLY/app_details ]]; then - unset PackageName - . "$REPLY/app_details" - [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/還原備份.sh" - fi - done - fi - done - else - echoRgb "更新當前${MODDIR##*/}目錄下備份相關腳本+tools目錄" - fi ;; - esac - else - cp -r "$TMPDIR/tools" "$MODDIR" - fi - rm -rf "$TMPDIR"/* - find "$MODDIR" -maxdepth 1 -name "*.zip" -type f -exec rm -rf {} \; - echoRgb "更新完成 請重新執行腳本" "2" && exit - fi ;; - *) - echoRgb "錯誤 請刪除當前目錄多餘zip\n -保留一個最新的數據備份.zip\n -下列為當前目錄zip\n$zippath" "0" && exit 1 ;; - esac -fi -#down -s -L "https://magisk-modules-repo.github.io/submission/modules.json" | jq -r '.modules[] | {id,prop_url,zip_url}' -#down -s -L "https://magisk-modules-repo.github.io/submission/modules.json" | jq -r '.modules[].zip_url' | egrep -w "riru_lsposed|busybox-ndk|riru_storage_redirect|riru-core|HideNavBar" | while read; do -# down -s -L -o "$MODDIR/${REPLY##*/}" "$REPLY" -#done \ No newline at end of file diff --git a/生成應用列表.sh b/生成應用列表.sh index 1eca1f5..968ee2b 100644 --- a/生成應用列表.sh +++ b/生成應用列表.sh @@ -55,4 +55,5 @@ done [[ -f $nametxt ]] && (cat "$nametxt" | sed -e '/^$/d' >"$nametxt.tmp" && mv "$nametxt.tmp" "$nametxt") || (echoRgb "$nametxt生成失敗" "0" && exit 2) endtime 1 [[ ! -e $MODDIR/tmp ]] && echoRgb "無新增應用" || echoRgb "輸出包名結束 請查看$nametxt" -rm -rf "$MODDIR/tmp" \ No newline at end of file +rm -rf "$MODDIR/tmp" +fead --help \ No newline at end of file