This commit is contained in:
YAWAsau
2022-01-01 14:47:43 +08:00
parent 55f549d047
commit 548fc19822
6 changed files with 447 additions and 395 deletions

View File

@@ -1,7 +1,7 @@
test "$(whoami)" != root && echo "你是憨批不給Root用你媽 爬" && exit 1
abi="$(getprop ro.product.cpu.abi)"
case $abi in
arm64*)
arm64*)
[[ $(getprop ro.build.version.sdk) -lt 28 ]] && echo "設備Android $(getprop ro.build.version.release)版本過低 請升級至Android 9+" && exit 1
;;
*)
@@ -18,15 +18,16 @@ if [[ -d $(magisk --path 2>/dev/null) ]]; then
PATH="$(magisk --path)/.magisk/busybox:$PATH"
else
echo "Magisk busybox Path does not exist"
fi ; export PATH="$PATH"
backup_version="V13.4"
fi
export PATH="$PATH"
backup_version="V13.4fix"
#設置二進制命令目錄位置
[[ $bin_path = "" ]] && echo "未正確指定bin.sh位置" && exit 2
[[ $bin_path == "" ]] && echo "未正確指定bin.sh位置" && exit 2
#bin_path="${bin_path/'/storage/emulated/'/'/data/media/'}"
Status_log="$MODDIR/Log.txt"
rm -rf "$Status_log"
filepath="/data/backup_tools"
if [[ $APP_ENV = 1 ]]; then
if [[ $APP_ENV == 1 ]]; then
filepath="/data/user/0/com.xayah.databackup/backup_tools"
fi
busybox="$filepath/busybox"
@@ -39,12 +40,12 @@ update
bin.sh"
if [[ ! -d $filepath ]]; then
mkdir -p "$filepath"
[[ $? = 0 ]] && echo "設置busybox環境中"
[[ $? == 0 ]] && echo "設置busybox環境中"
fi
[[ ! -f $bin_path/busybox_path ]] && touch "$bin_path/busybox_path"
if [[ $filepath != $(cat "$bin_path/busybox_path") ]]; then
[[ -d $(cat "$bin_path/busybox_path") ]] && rm -rf "$(cat "$bin_path/busybox_path")"
echo "$filepath">"$bin_path/busybox_path"
echo "$filepath" >"$bin_path/busybox_path"
fi
#刪除無效軟連結
find -L "$filepath" -maxdepth 1 -type l -exec rm -rf {} \;
@@ -89,7 +90,7 @@ export PATH="$filepath:$PATH"
export TZ=Asia/Taipei
TMPDIR="/data/local/tmp"
[[ ! -d $TMPDIR ]] && mkdir "$TMPDIR"
if [[ $(which busybox) = "" ]]; then
if [[ $(which busybox) == "" ]]; then
echo "環境變量中沒有找到busybox 請在tools/bin內添加一個\narm64可用的busybox\n或是安裝搞機助手 scene或是Magisk busybox模塊...."
exit 1
fi
@@ -113,18 +114,18 @@ Print() {
}
echoRgb() {
#轉換echo顏色提高可讀性
if [[ $2 = 0 ]]; then
if [[ $2 == 0 ]]; then
echo -e "\e[38;5;196m -$1\e[0m"
elif [[ $2 = 1 ]]; then
elif [[ $2 == 1 ]]; then
echo -e "\e[38;5;82m -$1\e[0m"
elif [[ $2 = 2 ]]; then
elif [[ $2 == 2 ]]; then
echo -e "\e[38;5;87m -$1\e[0m"
elif [[ $2 = 3 ]]; then
elif [[ $2 == 3 ]]; then
echo -e "\e[38;5;${en}m -$1\e[0m"
else
echo -e "\e[38;5;${bn}m -$1\e[0m"
fi
echo " -$(date '+%T') $1">>"$Status_log"
echo " -$(date '+%T') $1" >>"$Status_log"
}
get_version() {
while :; do
@@ -148,23 +149,26 @@ get_version() {
}
isBoolean() {
nsx="$1"
if [[ $1 = 1 ]];then
if [[ $1 == 1 ]]; then
nsx=true
elif [[ $1 = 0 ]];then
elif [[ $1 == 0 ]]; then
nsx=false
else
echoRgb "$MODDIR/backup_settings.conf $1填寫錯誤" "0" && exit 2
fi
}
echo_log() {
if [[ $? = 0 ]]; then
echoRgb "$1成功" "1" ; result=0
if [[ $? == 0 ]]; then
echoRgb "$1成功" "1"
result=0
else
echoRgb "$1失敗,過世了" "0" ; Print "$1失敗,過世了" ; result=1
echoRgb "$1失敗,過世了" "0"
Print "$1失敗,過世了"
result=1
fi
}
Open_apps="$(appinfo -d "(" -ed ")" -o ands,pn -ta c)"
Open_apps2="$(echo "$Open_apps" | cut -f2 -d '(' | sed 's/)//g')"
Open_apps2="$(echo "$Open_apps" | cut -f2 -d '(' | sed 's/)//g')"
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
@@ -182,10 +186,10 @@ if [[ $script != "" ]]; then
done
fi
fi
if [[ $(pm path ice.message) = "" ]]; then
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"
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
#sed -r -n 's/.*"tag_name": *"(.*)".*/\1/p'
#sed -r -n 's/.*"browser_download_url": *"(.*-linux64\..*\.so\.bz2)".*/\1/p'
@@ -196,13 +200,16 @@ if [[ -e $bin_path/update ]]; then
Language="https://api.github.com/repos/Petit-Abba/backup_script_zh-CN/releases/latest"
if [[ $LANG != "" ]]; then
case $LANG in
*-TW|*-tw)
*-TW | *-tw)
echoRgb "系統語系:繁體中文"
Language="https://api.github.com/repos/YAWAsau/backup_script/releases/latest" ;;
*-CN|*-cn)
echoRgb "系統語系:簡體中文" ;;
* )
echoRgb "$LANG不支持 默認簡體中文" "0" ;;
Language="https://api.github.com/repos/YAWAsau/backup_script/releases/latest"
;;
*-CN | *-cn)
echoRgb "系統語系:簡體中文"
;;
*)
echoRgb "$LANG不支持 默認簡體中文" "0"
;;
esac
else
echoRgb "獲取系統語系失敗 默認簡體中文" "0"
@@ -227,7 +234,7 @@ if [[ -e $bin_path/update ]]; then
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
if [[ $result == 0 ]]; then
echoRgb "update $backup_version > $tag"
zippath="$(find "$MODDIR" -maxdepth 1 -name "*.zip" -type f)"
GitHub="true"
@@ -247,14 +254,14 @@ 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
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
if [[ $result == 0 ]]; then
case $MODDIR in
*Backup_*)
if [[ -f $MODDIR/app_details ]]; then
@@ -296,7 +303,8 @@ if [[ $zippath != "" ]]; then
cp -r "$tools_path" "${MODDIR%/*}"
fi
fi
rm -rf "$tools_path/script" "$MODDIR/backup_settings.conf" "$MODDIR/backup.sh" "$MODDIR/Getlist.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
@@ -318,7 +326,8 @@ if [[ $zippath != "" ]]; then
done
else
echoRgb "更新當前${MODDIR##*/}目錄下備份相關腳本+tools目錄"
fi ;;
fi
;;
esac
else
cp -r "$TMPDIR/tools" "$MODDIR"
@@ -326,12 +335,14 @@ if [[ $zippath != "" ]]; then
rm -rf "$TMPDIR"/*
find "$MODDIR" -maxdepth 1 -name "*.zip" -type f -exec rm -rf {} \;
echoRgb "更新完成 請重新執行腳本" "2" && exit
fi ;;
fi
;;
*)
echoRgb "錯誤 請刪除當前目錄多餘zip\n -保留一個最新的數據備份.zip\n -下列為當前目錄zip\n$zippath" "0" && exit 1 ;;
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|ccbins" | while read; do
# down -s -L -o "$MODDIR/${REPLY##*/}" "$REPLY"
#done
#done