diff --git a/get-from-ecloud-with-unzip.sh b/get-from-ecloud-with-unzip.sh new file mode 100755 index 0000000000000000000000000000000000000000..21eeb3403e4d38b46a92a759f4f2b56997df585f --- /dev/null +++ b/get-from-ecloud-with-unzip.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (C) 2020 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 . + +# Parameter +# $1: ARCHIVE_URL +# $2: FOLDER (will be created if doesn't exist) + +# Exit status +# - 0 : archive downloaded +# - 1 : Generic error code (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 2 : Parse error—for instance, when parsing command-line options, the ‘.wgetrc’ or ‘.netrc’... (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 3 : File I/O error (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 4 : Network failure (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 5 : SSL verification failure (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 6 : Username/password authentication failure (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 7 : Protocol errors (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 8 : Server issued an error response (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html) +# - 10: No internet connection +# - 11: Invalid file downloaded +# - 101 : ARCHIVE_URL missing +# - 102 : FOLDER missing + +ARCHIVE_URL=$1 +FOLDER=$2 +ARCHIVE_NAME=$(basename $ARCHIVE_URL) +ARCHIVE_UNZIPPED=$FOLDER/$ARCHIVE_NAME.unzipped + +scripts/get-from-ecloud.sh $ARCHIVE_URL $FOLDER + +if [ -f $ARCHIVE_UNZIPPED ] +then + exit 0 +fi + +unzip -o -d $FOLDER $FOLDER/$ARCHIVE_NAME +touch $ARCHIVE_UNZIPPED diff --git a/get-from-ecloud.sh b/get-from-ecloud.sh index 514e43209a9108f274eb00bf61b432b3be9e1215..6d661ce67599b0c527cdde0599aedd855746a51d 100755 --- a/get-from-ecloud.sh +++ b/get-from-ecloud.sh @@ -36,6 +36,8 @@ ARCHIVE_URL=$1 FOLDER=$2 +FILENAME=$(basename ${ARCHIVE_URL}) +ARCHIVE_UNZIPPED=$FOLDER/$FILENAME.unzipped if ! curl -s -IL https://gitlab.e.foundation | grep -q "^HTTP\/2 200" @@ -54,7 +56,6 @@ then fi mkdir -p ${FOLDER} -FILENAME=$(basename ${ARCHIVE_URL}) wget -O ${FOLDER}/${FILENAME}.sha256sum ${ARCHIVE_URL}.sha256sum FOLDER_ESCAPED=$(echo ${FOLDER} | sed 's/\/$//' | sed 's/\//\\\//g') sed -i 's/\(.*\) \(.*\)/\1 '${FOLDER_ESCAPED}'\/\2/' ${FOLDER}/${FILENAME}.sha256sum @@ -66,6 +67,7 @@ then exit 0 fi +rm -f ${ARCHIVE_UNZIPPED} wget -O ${FOLDER}/${FILENAME} ${ARCHIVE_URL} sha256sum -c ${FOLDER}/${FILENAME}.sha256sum diff --git a/lock-bootloader.sh b/lock-bootloader.sh index aed5ed9a343dde07ae9a3b7731ef56bdd81899fc..7608300849760a3a2d78a67e1416106af91a8e03 100755 --- a/lock-bootloader.sh +++ b/lock-bootloader.sh @@ -29,4 +29,5 @@ then exit 101 fi +fastboot -s $DEVICE_ID erase config fastboot -s $DEVICE_ID flashing lock