Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ecbf3a14 authored by Aaron Kling's avatar Aaron Kling
Browse files

backuptool: Only run functions if check_prereqs succeeds

Based on Ic977dba675df58a228ef4b882b25beb66cc9d2c6

Change-Id: I19ea62c521df285cd3277ba4f385b408f49f6d83
parent 400e4fa4
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -47,13 +47,13 @@ restore_addon_d() {
check_prereq() {
# If there is no build.prop file the partition is probably empty.
if [ ! -r $S/build.prop ]; then
    exit 127
    return 1
fi
if ! grep -q "^ro.lineage.version=$V.*" $S/build.prop; then
  echo "Not backing up files from incompatible version: $V"
  exit 127
  return 2
fi
return 1
return 0
}

# Execute /system/addon.d/*.sh scripts with $1 parameter
@@ -93,23 +93,25 @@ determine_system_mount
case "$1" in
  backup)
    mount_system
    if check_prereq; then
        mkdir -p $C
    check_prereq
        preserve_addon_d
        run_stage pre-backup
        run_stage backup
        run_stage post-backup
    fi
    unmount_system
  ;;
  restore)
    mount_system
    check_prereq
    if check_prereq; then
        run_stage pre-restore
        run_stage restore
        run_stage post-restore
        restore_addon_d
        rm -rf $C
        sync
    fi
    unmount_system
  ;;
  *)