From 50ff2ac681b639d39847ec7bcda4b5bd2beb1c2f Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Fri, 3 May 2019 17:08:01 +0200 Subject: [PATCH 1/5] Init file --- wait-reboot.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 wait-reboot.sh diff --git a/wait-reboot.sh b/wait-reboot.sh new file mode 100644 index 0000000..c96163b --- /dev/null +++ b/wait-reboot.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Copyright (C) 2019 ECORP SAS - Author: Romain Hunault +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# TODO: test if a device go from "sideload" mode to recovery + +# Parameter +# $1: DEVICES_LOCKED_PATH temp folder where are stored locked devices + +# Return +# - displayed: DEVICE_ID device detected + +# Exit status +# - 0 : New device detected +# - 1 : Error +# - 101 : DEVICES_LOCKED_PATH missing + +DEVICES_LOCKED_PATH=$1 + +if [ -z $DEVICES_LOCKED_PATH ] +then + exit 101 +fi + + +function newDevice +{ + for device in $(adb devices | grep recovery | sed 's/\(.*\)\s*recovery/\1/') + do + if [ ! -f ${DEVICES_LOCKED_PATH}/${device} ] + then + echo ${device} + fi + done +} + +new_device=false + +while ! $new_device +do + DEVICE_ID=$(newDevice) + + if [ ! -z $DEVICE_ID ] + then + new_device=true + fi + + sleep 1 +done + +echo ${DEVICE_ID} + +sleep 10s -- GitLab From 5fc8f7141d7c5e1dfc962cc7657a3e91cc87b3a7 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Fri, 3 May 2019 17:38:02 +0200 Subject: [PATCH 2/5] Script to wait reboot from a device in recovery --- wait-reboot.sh | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) mode change 100644 => 100755 wait-reboot.sh diff --git a/wait-reboot.sh b/wait-reboot.sh old mode 100644 new mode 100755 index c96163b..1c56bf7 --- a/wait-reboot.sh +++ b/wait-reboot.sh @@ -18,49 +18,31 @@ # TODO: test if a device go from "sideload" mode to recovery # Parameter -# $1: DEVICES_LOCKED_PATH temp folder where are stored locked devices - -# Return -# - displayed: DEVICE_ID device detected +# $1: DEVICE_ID Device we are waiting for reboot # Exit status # - 0 : New device detected # - 1 : Error -# - 101 : DEVICES_LOCKED_PATH missing +# - 101 : DEVICE_ID is not detected -DEVICES_LOCKED_PATH=$1 +DEVICE_ID=$1 -if [ -z $DEVICES_LOCKED_PATH ] +if [ -z $DEVICE_ID ] then exit 101 fi - -function newDevice +function device_in_recovery { - for device in $(adb devices | grep recovery | sed 's/\(.*\)\s*recovery/\1/') - do - if [ ! -f ${DEVICES_LOCKED_PATH}/${device} ] - then - echo ${device} - fi - done + adb devices | grep recovery | grep ${DEVICE_ID} 2>&1 >/dev/null } -new_device=false +if ! device_in_recovery +then + exit 101 +fi -while ! $new_device +while device_in_recovery do - DEVICE_ID=$(newDevice) - - if [ ! -z $DEVICE_ID ] - then - new_device=true - fi - sleep 1 done - -echo ${DEVICE_ID} - -sleep 10s -- GitLab From 38439ef49b42741ac0be5dcee71db3338138a611 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 6 May 2019 13:20:23 +0000 Subject: [PATCH 3/5] Don't reboot after /e/ install --- install-e.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install-e.sh b/install-e.sh index 9f0fe3d..cf9dbb8 100755 --- a/install-e.sh +++ b/install-e.sh @@ -57,5 +57,3 @@ sleep 1 adb -s ${DEVICE_ID} shell rm /sdcard/${E_IMAGE} sleep 1 - -adb -s ${DEVICE_ID} reboot -- GitLab From 4b4eeabea0f4312866190eb5a37e00ab657ad8a5 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 6 May 2019 13:24:11 +0000 Subject: [PATCH 4/5] Fix documentation --- wait-reboot.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/wait-reboot.sh b/wait-reboot.sh index 1c56bf7..616d2eb 100755 --- a/wait-reboot.sh +++ b/wait-reboot.sh @@ -15,8 +15,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# TODO: test if a device go from "sideload" mode to recovery - # Parameter # $1: DEVICE_ID Device we are waiting for reboot -- GitLab From ce7bf4a2b7cfbfcefd270e5b6cbc3a9bba4468cc Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 7 May 2019 12:35:11 +0000 Subject: [PATCH 5/5] Fix exit status for parameter missing --- wait-reboot.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wait-reboot.sh b/wait-reboot.sh index 616d2eb..3f14c04 100755 --- a/wait-reboot.sh +++ b/wait-reboot.sh @@ -21,13 +21,14 @@ # Exit status # - 0 : New device detected # - 1 : Error +# - 10 : DEVICE_ID is missing # - 101 : DEVICE_ID is not detected DEVICE_ID=$1 if [ -z $DEVICE_ID ] then - exit 101 + exit 10 fi function device_in_recovery -- GitLab