diff --git a/tools/bin/bin.sh b/tools/bin/bin.sh index 23997b2..93a941b 100644 --- a/tools/bin/bin.sh +++ b/tools/bin/bin.sh @@ -19,7 +19,7 @@ if [[ -d $(magisk --path 2>/dev/null) ]]; then else echo "Magisk busybox Path does not exist" fi ; export PATH="$PATH" -backup_version="V12.9" +backup_version="V13" #設置二進制命令目錄位置 [[ $bin_path = "" ]] && echo "未正確指定bin.sh位置" && exit 2 #bin_path="${bin_path/'/storage/emulated/'/'/data/media/'}" @@ -30,8 +30,7 @@ case $MODDIR in /data/user/0/com.xayah.databackup*) if [[ -d /data/user/0/com.xayah.databackup ]]; then filepath="/data/user/0/com.xayah.databackup/backup_tools" - echo "於com.xayah.databackup內執行" && app="true" - [[ ! -e $bin_path/freq ]] && echo "1">"$bin_path/freq" + echo "於com.xayah.databackup內執行" fi ;; esac busybox="$filepath/busybox" @@ -211,7 +210,6 @@ if [[ $LANG != "" ]]; then else echoRgb "獲取系統語系失敗 默認簡體中文" "0" fi -[[ $app = true && $(cat "$bin_path/freq" 2>/dev/null) = 1 ]] && Mandatory_update="true" && freq="$(cat "$bin_path/freq" 2>/dev/null)" #dns="1.1.1.1,1.0.0.1" dns="8.8.8.8" #dns="114.114.114.114" @@ -227,28 +225,20 @@ else fi if [[ $json != "" ]]; then tag="$(echo "$json" | sed -r -n 's/.*"tag_name": *"(.*)".*/\1/p')" - if [[ $Mandatory_update != true ]]; then - if [[ $backup_version != $tag ]]; then - echoRgb "發現新版本 從GitHub更新 版本:$tag\n -更新日誌:\n$(curl "https://api.github.com/repos/YAWAsau/backup_script/releases/latest" 2>/dev/null | sed -r -n 's/.*"body": *"(.*)".*/\1/p' || down -s -L "https://api.github.com/repos/YAWAsau/backup_script/releases/latest" 2>/dev/null | sed -r -n 's/.*"body": *"(.*)".*/\1/p')" - download="$(echo "$json" | sed -r -n 's/.*"browser_download_url": *"(.*.zip)".*/\1/p')" - curl -O "https://gh.api.99988866.xyz/$download" || down -s -L -o "$MODDIR/$tag.zip" "https://gh.api.99988866.xyz/$download" - echo_log "下載${download##*/}" - if [[ $result = 0 ]]; then - echoRgb "update $backup_version > $tag" - zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)" - GitHub="true" - else - echoRgb "請手動將備份腳本壓縮包放置在\n -$MODDIR後再次執行腳本進行更新" "0" - fi - else - echoRgb "本地版本:$backup_version 線上版本:$tag 版本一致無須更新" - fi - else - echoRgb "首次使用 強制更新腳本\n -版本:$tag\n -更新日誌:\n$(curl "https://api.github.com/repos/YAWAsau/backup_script/releases/latest" 2>/dev/null | sed -r -n 's/.*"body": *"(.*)".*/\1/p' || down -s -L "https://api.github.com/repos/YAWAsau/backup_script/releases/latest" 2>/dev/null | sed -r -n 's/.*"body": *"(.*)".*/\1/p')" + if [[ $backup_version != $tag ]]; then + echoRgb "發現新版本 從GitHub更新 版本:$tag\n -更新日誌:\n$(curl "https://api.github.com/repos/YAWAsau/backup_script/releases/latest" 2>/dev/null | sed -r -n 's/.*"body": *"(.*)".*/\1/p' || down -s -L "https://api.github.com/repos/YAWAsau/backup_script/releases/latest" 2>/dev/null | sed -r -n 's/.*"body": *"(.*)".*/\1/p')" download="$(echo "$json" | sed -r -n 's/.*"browser_download_url": *"(.*.zip)".*/\1/p')" curl -O "https://gh.api.99988866.xyz/$download" || down -s -L -o "$MODDIR/$tag.zip" "https://gh.api.99988866.xyz/$download" echo_log "下載${download##*/}" - zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)" + if [[ $result = 0 ]]; then + echoRgb "update $backup_version > $tag" + zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)" + GitHub="true" + else + echoRgb "請手動將備份腳本壓縮包放置在\n -$MODDIR後再次執行腳本進行更新" "0" + fi + else + echoRgb "本地版本:$backup_version 線上版本:$tag 版本一致無須更新" fi else echoRgb "更新獲取失敗" "0" @@ -262,7 +252,7 @@ if [[ $zippath != "" ]]; then else cp -r "$tools_path" "$TMPDIR" && rm -rf "$tools_path" find "$MODDIR" -maxdepth 3 -name "*.sh" -type f -exec rm -rf {} \; - unzip -o "$zippath" -x "backup_settings.conf" -d "$MODDIR" + unzip -o "$zippath" -d "$MODDIR" echo_log "解壓縮${zippath##*/}" if [[ $result = 0 ]]; then case $MODDIR in @@ -270,43 +260,43 @@ if [[ $zippath != "" ]]; then 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" + cp -r "$tools_path/script/Get_DirName" "${MODDIR%/*}/DumpName.sh" + cp -r "$tools_path/script/restore" "${MODDIR%/*}/Restorebackup.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" + cp -r "$tools_path/script/restore2" "$MODDIR/Restorebackup.sh" else cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh" fi - if [[ -d ${MODDIR%/*/*}/tools && -f ${MODDIR%/*/*}/備份應用.sh ]]; then + if [[ -d ${MODDIR%/*/*}/tools && -f ${MODDIR%/*/*}/backup.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%/*/*}" + mv "$MODDIR/backup_settings.conf" "$MODDIR/backup.sh" "$MODDIR/Getlist.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" + cp -r "$tools_path/script/Get_DirName" "$MODDIR/DumpName.sh" + cp -r "$tools_path/script/restore" "$MODDIR/Restorebackup.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" + [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/Restorebackup.sh" fi done - if [[ -d ${MODDIR%/*}/tools && -f ${MODDIR%/*}/備份應用.sh ]]; then + if [[ -d ${MODDIR%/*}/tools && -f ${MODDIR%/*}/backup.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%/*}" + mv "$MODDIR/backup_settings.conf" "$MODDIR/backup.sh" "$MODDIR/Getlist.sh" "${MODDIR%/*}" cp -r "$tools_path" "${MODDIR%/*}" fi fi - rm -rf "$tools_path/script" "$MODDIR/backup_settings.conf" "$MODDIR/備份應用.sh" "$MODDIR/生成應用列表.sh" ;; + rm -rf "$tools_path/script" "$MODDIR/backup_settings.conf" "$MODDIR/backup.sh" "$MODDIR/Getlist.sh" ;; *) if [[ $(find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d) != "" ]]; then find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d | while read backup_path; do @@ -314,14 +304,14 @@ if [[ $zippath != "" ]]; then echoRgb "更新當前目錄下備份相關腳本&tools目錄+${backup_path##*/}內tools目錄+恢復腳本+tools" rm -rf "$backup_path/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" + cp -r "$tools_path/script/restore" "$backup_path/Restorebackup.sh" + cp -r "$tools_path/script/Get_DirName" "$backup_path/DumpName.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" + [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/Restorebackup.sh" fi done fi @@ -335,7 +325,6 @@ if [[ $zippath != "" ]]; then fi rm -rf "$TMPDIR"/* find "$MODDIR" -maxdepth 1 -name "*.zip" -type f -exec rm -rf {} \; - echo "$(("$freq"+1))" >"$bin_path/freq" echoRgb "更新完成 請重新執行腳本" "2" && exit fi ;; *)