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

Commit bc78a5e8 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

update wait-for-recovery.sh

parent a4f6c634
Loading
Loading
Loading
Loading
+20 −41
Original line number Diff line number Diff line
@@ -22,54 +22,33 @@
# $1: DEVICE_ID ID of the device to wait
# $2: ADB_FOLDER_PATH: the path where runnable adb is stored

# Return
# - displayed: DEVICE_ID device detected

# Exit status
# - 0 : New device detected
# - 1 : Error
# - 101 : DEVICES_LOCKED_PATH missing


# - 0 : success
# - 1 : twrp mount system failed
# - 101 : DEVICE_ID missing
# - 102 : adb wait recovery failed

ADB_FOLDER_PATH=$1
DEVICE_ID=$1
ADB_FOLDER_PATH=$2
ADB_PATH=""
DEVICE_ID=$2

if [ ! -z $ADB_FOLDER_PATH ]
if [ -z "$DEVICE_ID" ]
then
  ADB_PATH=${ADB_FOLDER_PATH}"adb"
else
  ADB_PATH=adb
  exit 101
fi

if [ ! -z $DEVICE_ID ]
then
  $ADB_PATH -s ${DEVICE_ID} wait-for-recovery
    if [ $? == 0 ]
    then
      $ADB_PATH -s ${DEVICE_ID} shell twrp mount system
      exit 0
    fi
fi

new_device=false

while ! $new_device
do
  DEVICE_ID=$(eval $ADB_PATH" get-serialno")
ADB_PATH=${ADB_FOLDER_PATH}"adb"

  if [ ! -z $DEVICE_ID ]
echo "waiting for recovery"
if "$ADB_PATH" -s "$DEVICE_ID" wait-for-recovery
then
    new_device=true
  fi
  sleep 1
done

$ADB_PATH -s ${DEVICE_ID} wait-for-recovery
if [ $? == 0 ]
    echo "device found in recovery"
    if ! "$ADB_PATH" -s "$DEVICE_ID" shell twrp mount system
    then
    $ADB_PATH -s ${DEVICE_ID} shell twrp mount system
        echo "twrp mount system failed"
        exit 1
    fi
else
    echo "device not detected in recovery"
    exit 102
fi
 No newline at end of file

echo ${DEVICE_ID}