Update
This commit is contained in:
parent
8845fb6fb2
commit
6a8d21b55e
@ -11,6 +11,9 @@ fi
|
|||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
find "$backupdir" -name "data.*.win*" ! -name '*.sha2' ! -name '*.info' -type f -exec tar -xvf {} --directory="$bashdir/$outdir" \;
|
for i in $(find "$backupdir" -name "data.*.win*" ! -name '*.sha2' ! -name '*.info' -type f); do
|
||||||
|
echo "Extracting file \"$i\""
|
||||||
|
pv $i | tar -x --overwrite -C "$bashdir/$outdir"
|
||||||
|
done
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
basedir="$PWD"
|
basedir="$PWD"
|
||||||
|
|
||||||
|
echo "Found main user"
|
||||||
|
ls "$basedir/work/data/data/" --format single-column --indicator-style none > "$basedir/work/packages_list_0.txt"
|
||||||
|
|
||||||
cd work/data/user
|
cd work/data/user
|
||||||
|
|
||||||
for USERID in *; do
|
for USERID in *; do
|
||||||
if [ -d "${USERID}" ]; then
|
if [ -d "${USERID}" ]; then
|
||||||
echo "${USERID}" # your processing here
|
echo "Found user ${USERID}"
|
||||||
ls "$basedir/work/data/user/$USERID/" --format single-column --indicator-style none > "$basedir/work/packages_list_${USERID}.txt"
|
ls "$basedir/work/data/user/$USERID/" --format single-column --indicator-style none > "$basedir/work/packages_list_${USERID}.txt"
|
||||||
fi
|
fi
|
||||||
ls "$basedir/work/data/data/" --format single-column --indicator-style none > "$basedir/work/packages_list_0.txt"
|
|
||||||
done
|
done
|
||||||
|
@ -34,15 +34,15 @@ remotepackages="/data/user/${USER_NUMBER}/"
|
|||||||
readarray -t packages < "work/packages_list_${BACKUP_USER_NUMBER}.txt"
|
readarray -t packages < "work/packages_list_${BACKUP_USER_NUMBER}.txt"
|
||||||
|
|
||||||
if [ -z "$BACKUP_USER_NUMBER" ]
|
if [ -z "$BACKUP_USER_NUMBER" ]
|
||||||
then
|
then
|
||||||
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$USER_NUMBER" ]
|
if [ -z "$USER_NUMBER" ]
|
||||||
then
|
then
|
||||||
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "=========================================================\n"
|
printf "=========================================================\n"
|
||||||
@ -57,44 +57,61 @@ printf "=========================================================\n"
|
|||||||
|
|
||||||
for package in ${packages[*]}
|
for package in ${packages[*]}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
printf "=========================================================\n"
|
printf "=========================================================\n"
|
||||||
adb shell am start -a android.intent.action.VIEW -d market://details?id=$package
|
if [[ $(curl -oIL -s -w "%{http_code}" "https://play.google.com/store/apps/details?id=$package") -eq 404 ]]; then
|
||||||
#while [ -n "$(adb shell "dumpsys activity | grep top-activity | grep 'com.android.vending'")" ]; do
|
echo "Skipping package \"$package\" because it's not on the play store."
|
||||||
# echo "wait..."
|
else
|
||||||
# sleep 1
|
adb shell am start -a android.intent.action.VIEW -d market://details?id=$package
|
||||||
#done
|
#while [ -n "$(adb shell "dumpsys activity | grep top-activity | grep 'com.android.vending'")" ]; do
|
||||||
echo "When you have the app installed, press volume UP to copy the data, press volume DOWN to skip"
|
# echo "wait..."
|
||||||
if [[ $(adb shell "getevent -l -v4 | grep -m1 --line-buffered KEY_VOLUME") == *"KEY_VOLUMEDOWN"* ]]; then
|
# sleep 1
|
||||||
echo "skipped $package"
|
#done
|
||||||
else
|
echo "When you have the app installed, press volume UP to copy the data, press volume DOWN to skip"
|
||||||
printf "Killing %s\n" $package
|
if [[ $(adb shell "getevent -l -v4 | grep -m1 --line-buffered -E -e \"KEY_VOLUME(UP|DOWN)[ ]+DOWN\"") == *"KEY_VOLUMEDOWN"* ]]; then
|
||||||
adb shell su -c "am force-stop --user $USER_NUMBER $package"
|
adb shell input keyevent KEYCODE_HOME
|
||||||
printf "Clearing %s\n" $package
|
echo "skipped $package"
|
||||||
adb shell su -c "pm clear --user $USER_NUMBER $package || true"
|
else
|
||||||
|
adb shell input keyevent KEYCODE_HOME
|
||||||
|
printf "Killing %s\n" $package
|
||||||
|
adb shell su -c "am force-stop --user $USER_NUMBER $package"
|
||||||
|
printf "Clearing %s\n" $package
|
||||||
|
adb shell su -c "pm clear --user $USER_NUMBER $package || true"
|
||||||
|
|
||||||
userid=$(adb shell su -c "stat -c '%u' $remotepackages$package") || $(adb shell su -c "dumpsys package $package" | grep userId | cut -d "=" -f2- | tr -d [:alpha:] | head -n 1)
|
echo "Local packages=$localpackages"
|
||||||
groupid=$(adb shell su -c "stat -c '%g' $remotepackages$package") || $(adb shell su -c "dumpsys package $package" | grep userId | cut -d "=" -f2- | tr -d [:alpha:] | head -n 1)
|
echo "Remote packages=$remotepackages"
|
||||||
echo "App UserId=$userid"
|
echo "Package=$package"
|
||||||
echo "App GroupId=$groupid"
|
userid=$(adb shell su -c "stat -c '%U' $remotepackages$package")
|
||||||
|
groupid=$(adb shell su -c "stat -c '%G' $remotepackages$package")
|
||||||
|
cacheuserid="${userid}"
|
||||||
|
cachegroupid="${groupid}_cache"
|
||||||
|
echo "App Data UserId=$userid"
|
||||||
|
echo "App Data GroupId=$groupid"
|
||||||
|
echo "App Cache UserId=$cacheuserid"
|
||||||
|
echo "App Cache GroupId=$cachegroupid"
|
||||||
|
|
||||||
printf "Compressing %s\n" $package
|
printf "Compressing %s\n" $package
|
||||||
tar cfz .tmp_$package.tar.gz -C $localpackages $package/
|
rm -r "$localpackages$package/cache" 2>/dev/null
|
||||||
printf "Copying %s\n" $package
|
rm -r "$localpackages$package/code_cache" 2>/dev/null
|
||||||
adb shell su -c "chown -R shell:shell /sdcard/.to_move"
|
tar cfz .tmp_$package.tar.gz -C $localpackages $package/
|
||||||
adb shell su -c "chmod -R 777 /sdcard/.to_move"
|
printf "Copying %s\n" $package
|
||||||
adb push .tmp_$package.tar.gz /sdcard/.to_move/.tmp_$package.tar.gz
|
adb shell su -c "chown -R shell:shell /sdcard/.to_move"
|
||||||
rm .tmp_$package.tar.gz
|
adb shell su -c "chmod -R 777 /sdcard/.to_move"
|
||||||
printf "Extracting %s\n" $package
|
adb push .tmp_$package.tar.gz /sdcard/.to_move/.tmp_$package.tar.gz
|
||||||
adb shell "su -c \"cd /sdcard/.to_move/ && tar xfzom /sdcard/.to_move/.tmp_$package.tar.gz -C $remotepackages && rm .tmp_$package.tar.gz\""
|
rm .tmp_$package.tar.gz
|
||||||
# printf "Restoring %s\n" $package
|
printf "Extracting %s\n" $package
|
||||||
# adb shell su -c "mv /sdcard/.to_move/$package $remotepackages"
|
adb shell "su -c \"cd /sdcard/.to_move/ && tar xfzom /sdcard/.to_move/.tmp_$package.tar.gz -C $remotepackages && rm .tmp_$package.tar.gz\""
|
||||||
printf "Correcting package\n"
|
# printf "Restoring %s\n" $package
|
||||||
adb shell su -c "chown -R \"$userid:$groupid\" \"$remotepackages$package\""
|
# adb shell su -c "mv /sdcard/.to_move/$package $remotepackages"
|
||||||
adb shell su -c "restorecon -R \"$remotepackages$package\""
|
printf "Correcting package\n"
|
||||||
printf "Package restored on device\n"
|
adb shell su -c "chown -R \"$userid:$groupid\" \"$remotepackages$package\""
|
||||||
sleep 1
|
adb shell su -c "chown -R \"$cacheuserid:$cachegroupid\" \"$remotepackages$package/cache\" 2>/dev/null"
|
||||||
fi
|
adb shell su -c "chown -R \"$cacheuserid:$cachegroupid\" \"$remotepackages$package/code_cache\" 2>/dev/null"
|
||||||
|
adb shell su -c "restorecon -R \"$remotepackages$package\""
|
||||||
|
printf "Package restored on device\n"
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
} || {
|
} || {
|
||||||
echo "Error"
|
echo "Error"
|
||||||
}
|
}
|
||||||
|
40
ab_fix.sh
40
ab_fix.sh
@ -1,19 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash -e
|
||||||
bashdir="$PWD"
|
bashdir="$PWD"
|
||||||
outdir="work"
|
outdir="work"
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "You must supply the path of the .ab file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
abfile=$(readlink -f "$1")
|
abfile=$(readlink -f "$1")
|
||||||
|
|
||||||
|
if [ -z "$abfile" ]
|
||||||
|
then
|
||||||
|
echo "You must supply the path of the .ab file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
outdir=$(readlink -f "$outdir")
|
outdir=$(readlink -f "$outdir")
|
||||||
mkdir -p "$outdir/ab_backup"
|
mkdir -p "$outdir/ab_backup"
|
||||||
|
|
||||||
#dd if="$1" bs=512 skip=3 | tar -x -C "$outdir/ab_backup"
|
|
||||||
#java -jar abe.jar unpack "$1" "$outdir/ab_backup.tar"
|
|
||||||
cd "$outdir/ab_backup"
|
cd "$outdir/ab_backup"
|
||||||
"$bashdir/twrpabx" "$abfile"
|
"$bashdir/twrpabx" "$abfile" > /dev/null
|
||||||
|
cd $bashdir
|
||||||
|
|
||||||
#tar -xf "$outdir/ab_backup.tar" -C "$outdir/ab_backup"
|
#Extract
|
||||||
|
for i in $(find "$outdir/ab_backup" -name "data.*.win*" ! -name '*.sha2' ! -name '*.info' -type f); do
|
||||||
|
echo "Extracting file \"$i\""
|
||||||
|
( pv $i | tar -x --overwrite -C "$outdir" ) || true
|
||||||
|
done
|
||||||
|
|
||||||
echo "The backup has been extracted to: \"$outdir/ab_backup\""
|
#Delete extracted backup directory
|
||||||
echo "Please use that path for the next steps"
|
rm -rf "$outdir/ab_backup"
|
||||||
|
|
||||||
|
#Fix directory structure
|
||||||
|
if [ -d "$outdir/user/0" ]
|
||||||
|
then
|
||||||
|
rmdir "$outdir/user/0"
|
||||||
|
fi
|
||||||
|
mv "$outdir/data" "$outdir/data_tmp"
|
||||||
|
mkdir -p "$outdir/data"
|
||||||
|
mv "$outdir/data_tmp" "$outdir/data/data"
|
||||||
|
mv "$outdir/user" "$outdir/data/user"
|
||||||
|
mv "$outdir/app" "$outdir/data/app"
|
||||||
|
Loading…
Reference in New Issue
Block a user