This commit is contained in:
YAWAsau
2021-12-22 18:39:56 +08:00
parent 684ee58677
commit 67e212dda0

View File

@@ -19,7 +19,7 @@ if [[ -d $(magisk --path 2>/dev/null) ]]; then
else else
echo "Magisk busybox Path does not exist" echo "Magisk busybox Path does not exist"
fi ; export PATH="$PATH" fi ; export PATH="$PATH"
backup_version="V12.9" backup_version="V13"
#設置二進制命令目錄位置 #設置二進制命令目錄位置
[[ $bin_path = "" ]] && echo "未正確指定bin.sh位置" && exit 2 [[ $bin_path = "" ]] && echo "未正確指定bin.sh位置" && exit 2
#bin_path="${bin_path/'/storage/emulated/'/'/data/media/'}" #bin_path="${bin_path/'/storage/emulated/'/'/data/media/'}"
@@ -30,8 +30,7 @@ case $MODDIR in
/data/user/0/com.xayah.databackup*) /data/user/0/com.xayah.databackup*)
if [[ -d /data/user/0/com.xayah.databackup ]]; then if [[ -d /data/user/0/com.xayah.databackup ]]; then
filepath="/data/user/0/com.xayah.databackup/backup_tools" filepath="/data/user/0/com.xayah.databackup/backup_tools"
echo "於com.xayah.databackup內執行" && app="true" echo "於com.xayah.databackup內執行"
[[ ! -e $bin_path/freq ]] && echo "1">"$bin_path/freq"
fi ;; fi ;;
esac esac
busybox="$filepath/busybox" busybox="$filepath/busybox"
@@ -211,7 +210,6 @@ if [[ $LANG != "" ]]; then
else else
echoRgb "獲取系統語系失敗 默認簡體中文" "0" echoRgb "獲取系統語系失敗 默認簡體中文" "0"
fi 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="1.1.1.1,1.0.0.1"
dns="8.8.8.8" dns="8.8.8.8"
#dns="114.114.114.114" #dns="114.114.114.114"
@@ -227,7 +225,6 @@ else
fi fi
if [[ $json != "" ]]; then if [[ $json != "" ]]; then
tag="$(echo "$json" | sed -r -n 's/.*"tag_name": *"(.*)".*/\1/p')" tag="$(echo "$json" | sed -r -n 's/.*"tag_name": *"(.*)".*/\1/p')"
if [[ $Mandatory_update != true ]]; then
if [[ $backup_version != $tag ]]; 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')" 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')" download="$(echo "$json" | sed -r -n 's/.*"browser_download_url": *"(.*.zip)".*/\1/p')"
@@ -243,13 +240,6 @@ if [[ $json != "" ]]; then
else else
echoRgb "本地版本:$backup_version 線上版本:$tag 版本一致無須更新" echoRgb "本地版本:$backup_version 線上版本:$tag 版本一致無須更新"
fi 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')"
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)"
fi
else else
echoRgb "更新獲取失敗" "0" echoRgb "更新獲取失敗" "0"
fi fi
@@ -262,7 +252,7 @@ if [[ $zippath != "" ]]; then
else else
cp -r "$tools_path" "$TMPDIR" && rm -rf "$tools_path" cp -r "$tools_path" "$TMPDIR" && rm -rf "$tools_path"
find "$MODDIR" -maxdepth 3 -name "*.sh" -type f -exec rm -rf {} \; 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##*/}" echo_log "解壓縮${zippath##*/}"
if [[ $result = 0 ]]; then if [[ $result = 0 ]]; then
case $MODDIR in case $MODDIR in
@@ -270,43 +260,43 @@ if [[ $zippath != "" ]]; then
if [[ -f $MODDIR/app_details ]]; then if [[ -f $MODDIR/app_details ]]; then
mv "$MODDIR/tools" "${MODDIR%/*}" mv "$MODDIR/tools" "${MODDIR%/*}"
echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+外部tools目錄" echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+外部tools目錄"
cp -r "$tools_path/script/Get_DirName" "${MODDIR%/*}/掃描資料夾名.sh" cp -r "$tools_path/script/Get_DirName" "${MODDIR%/*}/DumpName.sh"
cp -r "$tools_path/script/restore" "${MODDIR%/*}/還原備份.sh" cp -r "$tools_path/script/restore" "${MODDIR%/*}/Restorebackup.sh"
[[ -d ${MODDIR%/}/媒體 ]] && cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh" [[ -d ${MODDIR%/}/媒體 ]] && cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh"
. "$MODDIR/app_details" . "$MODDIR/app_details"
if [[ $PackageName != "" ]]; then if [[ $PackageName != "" ]]; then
cp -r "$tools_path/script/restore2" "$MODDIR/還原備份.sh" cp -r "$tools_path/script/restore2" "$MODDIR/Restorebackup.sh"
else else
cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh" cp -r "$tools_path/script/restore3" "${MODDIR%/*}/媒體/恢復多媒體數據.sh"
fi fi
if [[ -d ${MODDIR%/*/*}/tools && -f ${MODDIR%/*/*}/備份應用.sh ]]; then if [[ -d ${MODDIR%/*/*}/tools && -f ${MODDIR%/*/*}/backup.sh ]]; then
echoRgb "更新${MODDIR%/*/*}/tools與備份相關腳本" echoRgb "更新${MODDIR%/*/*}/tools與備份相關腳本"
rm -rf "${MODDIR%/*/*}/tools" rm -rf "${MODDIR%/*/*}/tools"
find "${MODDIR%/*/*}" -maxdepth 1 -name "*.sh" -type f -exec rm -rf {} \; 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%/*/*}" cp -r "$tools_path" "${MODDIR%/*/*}"
fi fi
else else
echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+tools目錄" echoRgb "更新當前${MODDIR##*/}目錄下恢復相關腳本+tools目錄"
cp -r "$tools_path/script/Get_DirName" "$MODDIR/掃描資料夾名.sh" cp -r "$tools_path/script/Get_DirName" "$MODDIR/DumpName.sh"
cp -r "$tools_path/script/restore" "$MODDIR/還原備份.sh" cp -r "$tools_path/script/restore" "$MODDIR/Restorebackup.sh"
[[ -d $MODDIR/媒體 ]] && cp -r "$tools_path/script/restore3" "$MODDIR/媒體/恢復多媒體數據.sh" [[ -d $MODDIR/媒體 ]] && cp -r "$tools_path/script/restore3" "$MODDIR/媒體/恢復多媒體數據.sh"
find "$MODDIR" -maxdepth 1 -type d | sort | while read; do find "$MODDIR" -maxdepth 1 -type d | sort | while read; do
if [[ -f $REPLY/app_details ]]; then if [[ -f $REPLY/app_details ]]; then
unset PackageName unset PackageName
. "$REPLY/app_details" . "$REPLY/app_details"
[[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/還原備份.sh" [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/Restorebackup.sh"
fi fi
done done
if [[ -d ${MODDIR%/*}/tools && -f ${MODDIR%/*}/備份應用.sh ]]; then if [[ -d ${MODDIR%/*}/tools && -f ${MODDIR%/*}/backup.sh ]]; then
echoRgb "更新${MODDIR%/*}/tools與備份相關腳本" echoRgb "更新${MODDIR%/*}/tools與備份相關腳本"
rm -rf "${MODDIR%/*}/tools" rm -rf "${MODDIR%/*}/tools"
find "${MODDIR%/*}" -maxdepth 1 -name "*.sh" -type f -exec rm -rf {} \; 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%/*}" cp -r "$tools_path" "${MODDIR%/*}"
fi fi
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 if [[ $(find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d) != "" ]]; then
find "$MODDIR" -maxdepth 1 -name "Backup_*" -type d | while read backup_path; do 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" echoRgb "更新當前目錄下備份相關腳本&tools目錄+${backup_path##*/}內tools目錄+恢復腳本+tools"
rm -rf "$backup_path/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" "$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/restore" "$backup_path/Restorebackup.sh"
cp -r "$tools_path/script/Get_DirName" "$backup_path/掃描資料夾名.sh" cp -r "$tools_path/script/Get_DirName" "$backup_path/DumpName.sh"
[[ -d $backup_path/媒體 ]] && cp -r "$tools_path/script/restore3" "$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 find "$MODDIR" -maxdepth 2 -type d | sort | while read; do
if [[ -f $REPLY/app_details ]]; then if [[ -f $REPLY/app_details ]]; then
unset PackageName unset PackageName
. "$REPLY/app_details" . "$REPLY/app_details"
[[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/還原備份.sh" [[ $PackageName != "" ]] && cp -r "$tools_path/script/restore2" "$REPLY/Restorebackup.sh"
fi fi
done done
fi fi
@@ -335,7 +325,6 @@ if [[ $zippath != "" ]]; then
fi fi
rm -rf "$TMPDIR"/* rm -rf "$TMPDIR"/*
find "$MODDIR" -maxdepth 1 -name "*.zip" -type f -exec rm -rf {} \; find "$MODDIR" -maxdepth 1 -name "*.zip" -type f -exec rm -rf {} \;
echo "$(("$freq"+1))" >"$bin_path/freq"
echoRgb "更新完成 請重新執行腳本" "2" && exit echoRgb "更新完成 請重新執行腳本" "2" && exit
fi ;; fi ;;
*) *)